Followup to SharePoint Contacts List on a Map from Google

In the Mapping Part 2 Comments, I received two questions I’ve been meaning to get back to.

  1. Can you do this if your list has latitude and longitude?
  2. How do you add the name to the popup?

Latitude and Longitude

The first step in modifying my example for latitude and longitude is adding the fields.

First I go to List Settings:

Then I create the latitude column:

Repeat for Longitude.

After creating a Collection on with my contact cities, I exported it to KML to find the latitude and longitude. View Collection.kml.

The HTML for the Content Editor Webpart is very similar to Part 1. Download GoogleMapsLatLonCEWP.html and open in SharePoint Designer to view the difference. Instead of a call to the Geocoder Object, we just pass the latitude and longitude fields straight in to new GLatLng as the point for the Marker. Feel free to drag the file from your download folder into a folder in SharePoint Designer to apply to your Content Editor Web Part.

Add Name

The XSLT from Part 2 received two changes for this update. In the showLocation call, I replaced Company with FirstName. I also repaced City and State with Latitude and Longitude in the same part of the stylesheet.

View GoogleMapsListMarkersLatLon.xml. Download to apply to your Data View Web Part.


You can see what it looks like live in the screenshot below.

Update 9/4/2019: Corrected two code sample links to a new github repo destination

  1. I am also having the same issue with only the first 10 records showing, other than that, everything is working fine with both addresses and lat/long.

    What is really frustrating me is that it was showing all the records earlier, and I can’t figure out what I changed that it is not only showing 10 under both scenarios.

  2. Hans, BJ, the 10 item limit has to do with the paging settings. Try playing around with a simple data view web part, changing the paging settings and look at the resulting XSLT changes. I will post a more detailed explanation as a new post when I get a chance. -Tom

  3. Thanx Tom.
    What would your approach be for displaying fields from records in the contactlist into Google Map’s infowindow? For example, I’d like to display the @Notes field in the window when clicking a marker.

  4. Hans,
    You can accomplish this in two steps. Modify the xslt to include @Notes after the @Longitude and modify the CEWP html to accept the Notes parameter and show it in the popup.
    Email me at if you want more detail.

  5. Thanks so much for posting this. My feedback is that if there are more than 10 items in the list, numbers 11+ don’t appear and the “View next” button isn’t available for the data view part of the page (in the XSLT, if I’m right) How do I modify the XSLT to give users the ability to page through the sets of records, and sort on the headers?

  6. It’s really sop cool. I am trying to implement it in SharePOint 2010, but AddMarkers() function is not working there and due to this pin points is not displaying. Last time I implemented it succesfully on MOSS2007. Please suggest something!!

  7. Praful,
    Thanks for reading and commenting. Can you share any more detail on what behavior you’re seeing including SharePoint Version number? I haven’t tried this in SharePoint 2010 yet, but I can’t think of any reason it wouldn’t work the same. AddMarkers is called in the initialize function which in turn should be called when the page loads by the following line:_spBodyOnLoadFunctionNames.push(“initialize”);
    As far as I know, that should all work the same.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.