Steven JW Kennedy

My Blog

Archive for the ‘SharePoint 2010’ Category

Microsoft SharePoint 2010

SP&GM: Step Four – Upload the JavaScript file

Posted by Steven Kennedy on April 18, 2011


Previous post in series: SP& GM: Step Three – Create a new Web Page and add a DataView

Next post in series: SP&GM: Step Five – Add a Content Editor web part [to be posted]

 

At the end of this post is the example JavaScript that I used to generate the Google Map. There’s also a link to a file with the code. Either copy or download the code and create a text file with it in. Don’t forget to replace the text, in the example code, ‘<insert your own Google Maps API key here>’ with your own Google Maps API key.

Upload the resulting text file to SharePoint. You can choose where you want to save this file to, a special Document Library for JavaScripts perhaps? In my case I just put it in the same Document Library as I’d created the web part web page. Once uploaded you’ll need to make a note of the URL for the file. I usually select the file and then select ‘View Properties’ from the dropdown. In the resulting properties display I right click on the name of the file and select ‘Copy shortcut’.

 

 

Previous post in series: SP& GM: Step Three – Create a new Web Page and add a DataView

Next post in series: SP&GM: Step Five – Add a Content Editor web part [to be posted]

Advertisements

Posted in Google, SharePoint 2010 | Tagged: , | Leave a Comment »

SP&GM: Step Two – Create your SharePoint List

Posted by Steven Kennedy on April 12, 2011


Previous post in series: SP&GM: Step One – Generate Lat/Long codes

Next post in series: SP&GM: Step Three – Create a new Web Page and add a DataView

You can either create a custom SharePoint List and manually enter the data or use an Excel file to create and populate the List.

In my case I used an Excel spreadsheet to generate the SharePoint List. As I had just under 200 entries I didn’t want to manually load the data. Unfortunately in generating the SharePoint List this way you don’t have a great deal of control over the field types. If you use my sample JavaScript you’ll need to have the field names the same and have them in the same order and once in SharePoint the field types will need to be the same (you can add additional columns to the right of the field Lat/Long as this wont impact the sample code). It’s highly likely that not all of these requirements will be met so I’ll describe in a later post in this series how I identified the various elements in order to extract the relevant information to be used to generate the Google Map.

The next three pictures depict various screens used to create a SharePoint List from an Excel Spreadsheet.

image

image

image

The picture below shows the various fields for my List, along with the field type. I’d also suggest at this time that you create a second view of the data, with a limited number of rows of data displayed. his will help during trouble shooting. If you have lots of data then each entry will be processed. By limiting the number of rows displayed we limit the number being processed. You could if you want just modify the default view to limit the number of items but I found it easier to have to separate views.

image_thumb[9]

Modify the Default view

The default ‘All Items’ view contains an  auto-generated column that we don’t need need so we’ll modify it to exclude it.

On the Ribbon select ‘List’ and then ‘List Settings’. Scroll to the bottom of the page and click on ‘All Items’, under the ‘Views’ heading. The ‘Columns’ section should be auto expanded, if not expand it. The first column listed should be ‘Attachments’. Uncheck the box next to it’s name and then click on ‘OK’.

Create a new View

Select the SharePoint List for which you want to create a new view. On the Ribbon select ‘List’ and then ‘List Settings’. Scroll to the bottom of the page and click on ‘Create view’. At the bottom of the page under the heading ‘Start from an existing view’ select All Items’. In the resulting dialog box type in a name for the view. I used ‘5 Records’. Scroll down to the bottom of the page and expand the section ‘Item Limit’. Set the ‘Number of items to display:’ to 5 and select the ‘Limit the total number of items …….’ radio button. Then select ‘OK’. You should then have a new view something like that shown below.

image_thumb[10]

Previous post in series: SP&GM: Step One – Generate Lat/Long codes

Next post in series: SP&GM: Step Three – Create a new Web Page and add a DataView

Posted in Google, SharePoint 2010 | Tagged: , | Leave a Comment »

SP&GM: Sample JavaScript

Posted by Steven Kennedy on April 11, 2011


First post in this series: SP & GM: Step One – Generate Lat/Long codes

A Word 2010 (.docx) version of the Example JavaScript, shown below, can be downloaded from here. You’ll need to open it in Word and then use ‘Save As’ to save it as a text (.txt) file.

Note! Replace the ‘<insert your own Google Maps API key here>’ with your own Google Maps API key. These can be obtained from Sign Up for the Google Maps API.

Posted in Google, SharePoint 2010 | Tagged: , | Leave a Comment »

SP&GM: Step One – Generate Lat/Long codes

Posted by Steven Kennedy on April 11, 2011


Previous post in series: Plotting SharePoint List Data on a Google Map – Part 2

Next post in series: SP&GM: Step Two – Create your SharePoint List

Using one of the Internet available sites generate a Lat/Long pair for each address that you have. In my case I had an Excel file with the addresses which I Cut & Pasted on to a site that generated the Lat/Long pairs. I used Batch Conversions of Address to Latitude/Longitude (Forward Geocoding) by Stephen P. Morse, but there are plenty around. I then took the resultant Lat/Long pairs and inserted them in to my Excel spreadsheet

I ended up with an Excel spreadsheet that looked something like this;

image

but with another 170 or so entries.

By going through this process, of generating the Lat/Long pairs, you can verify that the location information you’re using is accurate and that you get a good Lat/Long address. I found that in some cases the address I was using wasn’t entirely accurate. If the Address conversion cannot resolve the address it usually returns a 0,0. You can then investigate why. I found that in my case most of these were as a result of me using something like an ‘E’ in the address instead of ‘East’ etc.

Once you have the Excel spreadsheet save it for use in the next step.

 

Please note! that the example JavaScript that I provide in the post; SP&GM: Sample JavaScript, requires the Excel columns to be in the order shown in the picture above. In hindsight I didn’t really need the ‘Location’ column, that was a hold over from when I was using the Google Maps Geocode functionality.

 

Previous post in series: Plotting SharePoint List Data on a Google Map – Part 2

Next post in series: SP&GM: Step Two – Create your SharePoint List

Posted in Google, SharePoint 2010 | Tagged: , | 3 Comments »

Plotting SharePoint List Data on a Google Map – Part 2

Posted by Steven Kennedy on April 11, 2011


First off I’d like to acknowledge Kyle Schaeffer’s posting Plotting Your SharePoint 2010 List Data on a Google Map which I used as the starting point for my little project. I was also just going to make this a single post, as I implied in my initial post on this topic Plotting SharePoint List Data on a Google Map – Part 1, but as I started to write this post it got longer and longer, so I’ve broken it up in to multiple posts that I’ve listed below. You can either jump to the specific post of interest, or you can go through from Step One. Each post has a link to both the previous post and the next post in the series. The SP & GM used in the post titles indicate ‘SharePoint & Google Maps’, making it a little bit easier to identify the posts as part of the same series.

Scenario

What I wanted to do was take a set of address information and plot it on a Google Map, with the markers being clickable and showing various salient information about the location. In my case I mocked up some location information to emulate a company with sites across the USA, along with the number of employees at each site. You could also use something similar to indicate what type and or the size of the sites network connections. Does it have direct Internet access etc. For my example I’m keeping it simple, Location and number of employees. Also, instead of using Google’s geocoder function, to resolve an address to a Lat/Long, I’m going to provide the Lat/Long as part of the SharePoint List data. This means some additional up front work, and ongoing as new locations are added but this is off-set by the issues created in trying to use the geocoder functionality for something like 200 locations and the various limitations imposed by using the free capability that Google provides.

Requirements to use these posts to do the something similar;

  • SharePoint 2010, and appropriate access to be able to create;
    • a SharePoint 2010 List
    • a web part web page
    • use SharePoint Designer 2010 to edit the web part web page (some companies may have restricted this capability. In which case you’re out of luck and you wont be able to follow these instructions.)
  • A set of data, including location information, that you wish to plot using Google Maps

Note! This example makes use of the Google Maps V2 API (which has been deprecated already, but still works) along with jQuery.

Additional posts in this series

If you follow the steps outlined above you should be able to end up with a Google Maps displayed on a SharePoint page that looks something like;

image_thumb[10][1]

Posted in Google, SharePoint 2010 | Tagged: , | 4 Comments »