SharePoint 2013 comes with tons of enhancements and modifications to previous versions of the product. One of the cool features I’ve played around with lately is the Geolocation field. Back in 2010 I wrote a custom-coded solution for displaying location information in our SharePoint lists, integrating some fancy-pants Google Maps – in SharePoint 2013, a similar field exist out of the box.
In this article I’ll mention what this field does, a sample of creating and using the field, getting and setting the Bing Maps keys to make sure our maps are properly working and displaying.
Update 2013-09-14: As pointed out by Leon Zandman in the comments, there’s a some updated pre-requisites required in order to view the geolocation field value or data in a list. Information from Microsoft:
An MSI package named SQLSysClrTypes.msi must be installed on every SharePoint front-end web server to view the geolocation field value or data in a list. This package installs components that implement the new geometry, geography, and hierarchy ID types in SQL Server 2008. By default, this file is installed for SharePoint Online. However, it is not for an on-premises deployment of SharePoint Server 2013. You must be a member of the Farm Administrators group to perform this operation. To download SQLSysClrTypes.msi, see Microsoft SQL Server 2008 R2 SP1 Feature Pack for SQL Server 2008, or Microsoft SQL Server 2012 Feature Packfor SQL Server 2012 in the Microsoft Download Center.
Introduction to the Geolocation Field
I’ll showcase what the Geolocation field can do for us in a SharePoint list. In the sample below I’ve used a list called “Scandinavian Microsoft Offices” which contains a few office names (Sweden, Denmark, Finland and Norway). What I want to do in my list is to display the location visually to my users, not only the name and address of the location. With the new Geolocation field you can display an actual map, as I’ll show you through right now – skip down to the “Adding a Geolocation Field to your list” section if you want to know how to get the same results yourself.
A plain SharePoint list before I’ve added my Geolocation field

As you can see, no modifications or extra awesomeness exist in this list view – it’s a vanilla SharePoint 2013 list view.
The same list, with the Geolocation field added to it
When we’ve added the Geolocation field to support our Bing Maps, you can see that a new column is displayed in the list view and you can interact with it. In my sample here I’ve filled in the coordinates for the four Microsoft offices I’ve listed in my list.

Pressing the small globe icon will bring up a nice hover card kind of dialog with the actual map, with options to view the entire map on Bing Maps as well (which is essentially just a link that’ll take you onwards to the actual bing map):

Viewing an actual list item looks like this, with the map fully integrated by default into the display form:

And should you want to Add or Edit a list item with the Geolocation field, you can click either “Specify location” or “Use my location“. If you browser supports the usage and tracking of your location, you can use the latter alternative to have SharePoint automagically fill in your coordinates for you. Compare it with how you check in at Facebook and it recognizes your current location and can put a pin on the map for you.

In my current setup I don’t have support for “Use my location” so I’ll have to go with the “Specify location” option – giving me this pretty dull dialog:

As you can see, you don’t have an option for searching for your office on Bing Maps and then selecting the search result and have it automatically insert the correct Lat/Long coordinates. But, that’s where developers come in handy.
Create a new Map View
Let’s not forget about this awesome feature – you can create a new View in your list now, called a “Map View”, which will give you a pretty nice map layout of your tagged locations with pins on the map. Check these steps out:
1) Head on up to “List” -> “Create View” in your List Ribbon Menu:

2) Select the new “Map View”

3) Enter a name, choose your fields and hit “Ok”
4) Enjoy your newly created out of the box view in SharePoint. AWESOME

Adding a Geolocation Field to your list
Right, let’s move on to the fun part of actually adding the field to our list. I’m not sure if it’s possible to add the field through the UI in SharePoint but you can definitely add it using code and scripts, which is my preferred way to add stuff anyway.
Adding a Geolocation field using PowerShell
With the following PowerShell snippet you can easily add a new Geolocation field to your list:
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb "http://tozit-sp:2015"
$list = $web.Lists["Scandinavian Microsoft Offices"]
$list.Fields.AddFieldAsXml( "", $true, [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
Adding a Geolocation field using the .NET Client Object Model
With the following code snippet for the CSOM you can add a new Geolocation field to your list.
// Hardcoded sample, you may want to use a different approach if you're planning to use this code :-)
var webUrl = "http://tozit-sp:2015";
ClientContext ctx = new ClientContext(webUrl);
List officeLocationList = ctx.Web.Lists.GetByTitle("Scandinavian Microsoft Offices");
officeLocationList.Fields.AddFieldAsXml( "", true, AddFieldOptions.AddToAllContentTypes);
officeLocationList.Update();
ctx.ExecuteQuery();
Adding a Geolocation field using the Javascript Client Object Model
With the following code snippet for the JS Client Object Model you can add a new Geolocation field to your list:
function AddGeolocationFieldSample()
{
var clientContext = new SP.ClientContext();
var targetList = clientContext.getweb().getlists().getByTitle('Scandinavian Microsoft Offices');
fields = targetList.get_fields();
fields.addFieldAsXml("", true, SP.AddFieldOptions.addToDefaultContentType);
clientContext.load(fields);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onContextQuerySuccess), Function.createDelegate(this, this.onContextQueryFailure));
}
Adding a Geolocation field using the Server Side Object Model
With the following code snippet of server-side code you can add a new Geolocation field to your list:
// Assumes you've got an SPSite object called 'site'
SPWeb web = site.RootWeb;
SPList list = web.Lists.TryGetList("Scandinavian Microsoft Offices");
if (list != null)
{
list.Fields.AddFieldAsXml("", true, SPAddFieldOptions.AddFieldToDefaultView);
}
Be amazed, its that easy!
Bing Maps – getting and setting the credentials in SharePoint
Okay now I’ve added the fields to my lists and everything seems to be working out well, except for one little thing… The Bing Map tells me “The specified credentials are invalid. You can sign up for a free developer account at http://www.bingmapsportal.com“, which could look like this:

Get your Bing Maps keys
If you don’t have any credentials for Bing Maps, you can easily fetch them by going to the specified Url (http://www.bingmapsportal.com) and follow these few simple steps.
1) First off (after you’ve signed up or signed in), you’ll need to click on the “Create or view keys” link in the left navigation:

2) Secondly, you will have to enter some information to create a new key and then click ‘Submit’:

After you’ve clicked ‘Submit’ you’ll be presented with a list of your keys, looking something like this:

Great, you’ve got your Bing Maps keys/credentials. Now we need to let SharePoint know about this as well!
Telling SharePoint 2013 what credentials you want to use for the Bing Maps
Okay – so by this time we’ve created a Geolocation field and set up a credential for our key with Bing Maps. But how does SharePoint know what key to use?
Well that’s pretty straight forward, we have a Property Bag on the SPWeb object called “BING_MAPS_KEY” which allows us to configure our key.
Since setting a property bag is so straight forward I’ll only use one code snippet sample to explain it – it should be easily translated over to the other object models, should you have the need for it.
Setting the BING MAPS KEY using PowerShell on the Farm
If you instead want to configure one key for your entire farm, you can use the Set-SPBingMapsKey PowerShell Cmdlet.
Set-SPBingMapsKey -BingKey "FFDDuWzmanbiqeF7Ftke68y4K8vtU1vDYFEWg1J5J4o2x4LEKqJzjDajZ0XQKpFG"
Setting the BING MAPS KEY using PowerShell on a specific Web
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb "http://tozit-sp:2015"
$web.AllProperties["BINGMAPSKEY"] = "FFDDuWzmanbiqeF7Ftke68y4K8vtU1vDYFEWg1J5J4o2x4LEKqJzjDajZ0XQKpFG"
$web.Update()
Update 2013-03-31: More examples of setting the property bag
I got a comment in the blog about having more examples for various approaches (like CSOM/JS and not only PowerShell). Sure enough, here comes some simple samples for that.
Setting the BING MAPS KEY using JavaScript Client Object Model on a specific Web
var ctx = new SP.ClientContext.getcurrent(); var web = ctx.getsite().getrootWeb(); var webProperties = web.getallProperties(); webProperties.setitem("BINGMAPS_KEY", "FFDDuWzmanbiqeF7Ftke68y4K8vtU1vDYFEWg1J5J4o2x4LEKqJzjDajZ0XQKpFG"); web.update(); ctx.load(web); // Shoot'em queries away captain! ctx.executeQueryAsync(function (){ alert("Success"); },function () { alert("Fail.. Doh!"); });
Setting the BING MAPS KEY using .NET Client Object Model on a specific Web
// Set the Url to the site, or get the current context. Choose your own approach here..
var ctx = new ClientContext("http://tozit-sp:2015/");
var siteCollection = ctx.Site;
ctx.Load(siteCollection);
var web = siteCollection.RootWeb;
ctx.Load(web, w => w.AllProperties);
ctx.ExecuteQuery();
var allProperties = web.AllProperties;
ctx.Load(allProperties);
// Set the Bing Maps Key property
web.AllProperties["BINGMAPSKEY"] = "FFDDuWzmanbiqeF7Ftke68y4K8vtU1vDYFEWg1J5J4o2x4LEKqJzjDajZ0XQKpFG";
web.Update();
ctx.Load(web, w => w.AllProperties);
ctx.ExecuteQuery();
So that’s pretty straight forward. Once you’ve set the Bing Maps Key, you can see that the text in your maps has disappeared and you can now start utilizing the full potential of the Geolocation field.
Summary
The Geolocation field is pretty slick to play around with. It leaves a few holes in terms of functionality that we’ll have to fill ourselves – but of course that depends on our business requirements. One example is that I rarely want to enter the coordinates into the Geolocation field myself, but I might just want to do a search and select a location which is the added and the coordinates populated into the field automatically, or use the (built in) functionality of “Use my location” – good thing we’ve got developers to fine-tune this bits and pieces :-)
Enjoy.
Comments are closed
Archived comments
Very slick Tobias. As you know I am doings something similar, except I am taking mine Mobile using just HTML5 and JavaScript, but I always wanted to see what my integration points would be in SharePoint. I like what you have done, and I will see what I can do to extend it, especially around the fields as you mentioned above.
Thanks Fabian, appreciated.
Sounds awesome - would be interesting to hear more once it all comes together.
A cool thing would be to have a search-box in the Edit/Add dialog so you can do an immediate search and pick a result, which auto-populates the field with the proper coordinates for the selected location. Shouldn't be too hard to accomplish and would benefit a lot!
Cheers,
Tob.
Tobias, It's posts like this that make me say...How the heck did you figure this out in the first place?? Very Cool! Now I want to try the mobile UI.
Thanks Matt. It's pretty slick. I haven't tested this in production yet, so I don't know what the potential pitfalls are yet - but I do like what I'm seeing and so far the Geolocation field seems awesome! Working on adding some functionality to it by extending it or potentially injecting some jQuery madness onto the forms :-)
I just updated the article with the Set-SPBingMapsKey PowerShell cmdlet.
You should hide your Bing maps key, even if it is just for testing purposes. It's linked to you and your account.
Hey Dennis,
Thanks for the tip - but the keys are already obfuscated. I edited the image and snippets with non-personal keys :-)
Excellent post. Thank you!! It's great to see so many screenshots of this new feature. Definitely a win for power users with geolocation data today in a plain custom list. Keep up the good work.
I assume with SPWeb property bag, it should be possible to set the BING MAP KEY remotely also. For power users on a system where the admin didn't set a key, it might be nice to have a JS/CSOM code snippet.
Hi Jeff - thanks, appreciate it!
As long as you can access your SPWeb property bags, you can set the Bing Map Key. So if you have access and permissions to do it - you should be able to ser it using CSOM/JS just like you mention. I could update post and add a CSOM and JS sample for updating the property bags as well.
Cheers,
Tob.
I just updated the article with examples of updating the property bag for the Bing Map Key using .NET Client Object Model and the JS/EcmaScript Client Object Model. Enjoy :-)
I like it :)
Appreciate it mate.
Cheers,
Tob.
Thank you! I've done this on-prem using http://msdn.microsoft.com/e... ... how would you go about adding to SP Online (Office 365) - is it possible?
Nice! Have you tried using the JS Client Object Model for creating the field in SP Online? I haven't tried it yet, but if the field exist in SharePoint Online, which I suppose, then you should be able to create it fairly simply using the JS approach above for example. Or pushing the code into a .NET CSOM application.
This is a great write-up but I was having trouble making it work on SharePoint Online. Then I found a post that took what Tobias wrote here and created an easy to setup Javascript/HTML form on your site that sets everything up for you. I can confirm that it works well on SP online. http://mysharepointinsight....
Great post. But when I went to apply it I didn't found the "Map View" Type in view types
Hi Mohammad,
Thank you for the comment.
Did you first create the Geolocation field so it exist in you list before you try to create a new View based on the Map View type?
Cheers,
Tobias.
oh,,, I am sorry, I am new to SharePoint. I didn't find the column of type geolocation.
No worries Mohammad, we've all been there at some point :-)
In order for the View of the type "Map View" to appear in your list I recommend you to have at least one Geolocation field in your list.
Follow the guidelines I've mentioned under the headline "Adding a Geolocation Field to your list" in this article and you'll see different ways to add a Geolocation field to your own lists. Once you've added it, you can create the Map View and the awesomeness is rocking and rolling!
Cheers,
Tobias.
Thanks very match...
You are most welcome Mohammad. Enjoy SharePoint :-)
Tobias.
Great post. Really liked the geolocation field as part of SHarePoint 2013 and the integration possiblilties that we can achive with that filed. This can be really helpful for the contacts list where we have address information
Hi Premchand,
Thanks. Yes it's a pretty cool new addition to the field stack in SharePoint. We're using it for office locations, contact lists and social activitiy lists at the moment with some clients and it works great thus far.
Cheers,
Tob.
how to use geolocation field in web part or IMTECH CQWP ?
Hi Ahmed,
It depends on what your objectives are, and how you want the final solution to work.
Regards,
Tobias.
Did you install that prerequisite "SQLSysClrTypes.msi" that Microsoft talks about in their docs? http://msdn.microsoft.com/e...
Hey Leon,
I can't really recall ever installing that one actually. I'm doing my stuff on-premise too.
It seems to work just fine as it is. I'm currently working on a client's Production(!) farm, so no experimenting / installing stuff without permission :-) Maybe the prerequisite has already been installed as part of some previous update.
Hey L,
Well I'm pretty sure I haven't installed it either, even if I can't swear myself free from it. Might be included with other updates as you mention - important thing is that everything works as expected :-)
OK, I did some research and the problem surfaces when you actually try to save a location after specifying it using the Lat/Lon dialog. If that SQL CLR Types prerequisite isn't installed on the WFEs you'll get the following error message after pressing the "Save" button below the Bing map:
"A required component for using a geolocation field is not installed. Either go to the list settings page to delete this field or contact your administrator."
Maybe it's wise after all to update your article and include this tidbit :-)
Great Leon.
I've updated the post to include a reference to the link :)
Cheers,
Tob.
Hello - I originally tried running the powershell script without installing the SQL .msi and experienced this error when trying to save the Lat/Longitude. I found this article afterward and installed the .msi, but I'm still getting the same, "A required component for using a geolocation field is not installed. Either go to the list settings page to delete this field or contact your administrator." error.
Any ideas? Does the order in which those two things are done matter?
Thanks,
Joe
IISRESET will help in that scenario.
dose Geolocation field save data or read in Spatial Data formats. and via BCS can i use Spatial data Source and exposed data in SharePoint. ?
Good day,
I'm trying to return the Geolocation in SharePoint Search results page.
Any idea how this can be done? I've been trying to add a managed property type of 'Geolocation' as well but haven't been able to succeed.
Regards,
How to Populate your GEOLocation with PowerShell. This assumes that you already have a longitude and latitude co-ordinate in your list.
I tested with the following data http://data.gov.au/dataset/...
You can import the spreadsheet using the "Import Spreadsheet App" to create a list and then add the GeoField. After this you need to convert the Long + Lat to POINT ( long lat ) and your done - here's the PowerShell
Add-PSSnapin Microsoft.SharePoint.Powershell
$webUrl = "http://sharepoint13/resource"
$listName = "Schools"
$web = Get-SPWeb $webUrl
$fieldXml = "<field type="Geolocation" displayname="Location"/>"
$list = $web.Lists[$listName]
$list.Fields.AddFieldAsXml($fieldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::Default)
$list.Update()
foreach ($item in $list.Items)
{
$long = $item["long"]
$lat = $item["lat"]
$loc = "POINT ($long $lat)"
$item["Location"] = $loc
$item.Update()
}
Hi Tobias, Many Thanks for sharing this, excellent guidance to expose a great feature. Works like a charm.
Hi HGB,
Thank you for your comment - appreciate it, and I'm glad it works well for you :-)
Cheers,
Tobias.
Nice Post
I have created the column via the PowerShell script, set my Bing maps key at the farm level, and installed SQLSysClrTypes.msi on my web server. When I go to add an item and use my current location, if I try to save, I get "A required component for using a geolocation field is not installed. Either go to the list settings page to delete this field or contact your administrator." I set the Bing maps key at the web level to see if that worked. It didn't. Nothing in the logs. Any idea where I might have went wrong?
nice! this is exactly what i was looking for!!
Hi Tomas,
I'm glad you enjoyed it.
Cheers,
Tobias.
Great write up, Tobias. Thank you. I've just launched a project on CodePlex to provide a UI for geolocation management and would love your input and feedback. It's beta now and needs work, but will make for a nice side project: http://sp2013geolocationman....
I'm glad you liked it and found the post useful.
Cheers,
Tobias.
Hi Tobias,
Thanks for this, I'm struggling with setting the bing maps key using PowerShell connected to our 365/E3 sharepoint online. I'm getting an error saying that the term 'Set-SPBingMapsKey' is not recognized, do you have any pointers (sorry I'm a bit new to all this, I'm sure it must just be a school boy error, but I'm completely stuck!).
Not to worry - followed the link posted below (http://mysharepointinsight.... and all is well :)
Hi James,
Glad you got it sorted. I'll update my article to point to the mentioned link for SPO/O365 configurations.
Cheers,
Tobias.
Hi Tobias,
I have added the Avior GEO Location Utility App to my SharePoint Site but i am not able to add the Geo Location column from my Mobile Phone..
Hi Mayur,
Thank you for your comment. This article focus on getting started with creating your own Geo-location fields, and the one you mentioned was designed and developed by a third party. I would suggest you contact their support if the product doesn't work as expected or if you have questions for them :-)
Regards,
Tobias.
Does anyone know how to add the location column as a custom site column, so that I wouldn’t have to do this every time I wanted it in a library. Or does anyone know how to hide the details of an item until that item is selected?
Awesome, thank you!
Thumbs up Matthew :-)
Cheers,
Tob.
Is OpenSearch endpoint able to use this geospatial field to do geospatial open search query?
How to post geolocation values to a Share point list field with rest api? Please tell me the JSON format. I have tried many different formats but none worked. I get the error "Cannot deserialize data for type Microsoft.SharePoint.SPFieldGeolocationValue".
Very nice and informative article here. Thanks for the sharing, I also found a useful service for docs merging. Try AltoMerge to merge your PDF files here Alto-Merge. It allows you to merge files in different formats.
Hi Tobias, a potentially curly one here. I have geolocation up and running perfectly. I coupled this with a workflow that takes the wic_System_GPS_Latitude and wic_System_GPS_Longitude exif data and converts it to X,Y and updates the geolocation column. This works fine and ultimately means that the user does not need to work out the X,Y in order to see the location on Bing maps.
So far so good. Now I needed to deploy this workflow out to another site collection so I created a reusable workflow based on the image content type. The image content type in the source site contains the 3 necessary columns; long/lat/geo. I then deploy my workflow to the destination site collection and activated it. Finally I associate my workflow to my other library (which already has the 3 custom columns added and the workflow errors when I add a new image.
When I open up my workflow in sharepoint designer I see that the set field action has gone from set location to <formula> to set FIELD to <formula>
Do you know of any reason why this reference would break in transit/activation/list association?
Great article indeed!
If anyone needs it, I have a freely downloadable solution that adds the missing pieces that you mention and for some reason Microsoft left out, namely a UI that lets you set the Bing Maps key without PowerShell or code and an address look-up extension which enables you to set the location via a street address stored in a column on the list instead of expecting users to know the Lat and Long.
Details and download can be found in my blog post http://www.kaboodlekonnect....
BTW, for anyone in Australia I am showcasing this (and some other cool stuff I've been working on) at the O365 community events this year (2016).
I'm thinking of creating the equivalent solution for O365 is there is enough people who reach out and tell me its worth doing.
Hello Tobias, we've walked this thru a few times now and like several of the others below we get the error when a user tries to save a new item.
We have SharePoint 2013 Enterprise using SQL Server 2014 both updated to the latest service packs and all "current" updates. We've installed the Microsoft CLR Types for SQL Server 2014 SP2 (SQLSysClrTypes.msi) on the WFE server and everything looked good. However we get the error: "A required component for using a geolocation field is not installed. Either go to the list settings page to delete this field or contact your administrator." when we try to add a new item or edit an item with the Geolocation field.
We've done the iisreset and even the reboot, any ideas would be greatly appreciated.
David,
Did you ever find a way to fix this? I'm having the same problem
Thanks!
I figured it out. You must install the feature pack for SQL Server 2012 SP2. The new version for 2014 will not work.
Hi Tobias
Do you know if there is a way to change the default view of the map from Street View to Aerial / Satellite view? I've got this all working in a SharePoint Online List, but I cant figure out how to change the map view.
Hi @disqus_SKmymAaQaw:disqus ,
Unfortunately I haven't worked with this type of field for a long time, so I wouldn't know from the top of my head. If you figure it out, feel free to come back here and leave a comment with the solution, as I'm sure others could benefit too :)
Cheers,
Tobias.
Great, didn't know it. Is there more hidden stuff?