Sunday, May 5, 2013

Adding geolocation field to SharePoint Online

One of the hidden gems in Sharepoint is the new geolocation field. Geolocation field enables you to annotate SharePoint lists with location information. In columns of type Geolocation, you can enter location information as a pair of latitude and longitude coordinates. The reason it is hidden is because it is not available by default in SharePoint list and there is also no user interface to add it. The only way to add it is through code or powershell. There are already many posts with code samples for adding geolocation field so that wont be the topic of this post. I would suggest to you to check out this post if you want to get a good insight in those code samples. This post will describe how I have created a small wizard form for adding those fields to my SharePoint lists. I am using pure HTML and javascript so this will work both in SharePoint Online and in your on premise environment. First create a page where you wish to place this wizard. On that page add a Script Editor web part. In this web part we will add both our javascript methods and our html.
First add this javascript:

And after that add this HTML form:

Web relative URL: &nbsp
Bing Maps Key: &nbsp
List name: &nbsp
Field name: &nbsp

This will be your end result:

And now you have your form for adding geolocation field anywhere on your site collection. Once you have entered relative path to your web ("/" is root web) you can use Get Bing key to check if you have a BING maps key placed in that web and with Set BING key you can change or add a BING maps key to that web.

And once you enter List name and Field name you can use Create field to add a geolocation field with the name you specified to the list on the web.

Hope this helps you create you geolocation fields faster.


  1. Thanks for putting this all together. I have been banging my head against this for the last couple of days mainly because I am on SharePoint Online. I followed your instructions above and was up and running with a working geolocation field in a matter of minutes.

  2. I have been trying to get this to work with out SP online site and all I get is object expected errors when trying to get the Client Context. Any ideas what might be wrong?

  3. AWESOME POST! Worked as advertised Office365/E3 subscription.

  4. My man! Took like 2 minutes to implement.

    Thanks for your contribution.

  5. You are simply the best!!! was trying for hours to get this done via PowerShell - but your solution is fantastic!!! congratulations!!!

  6. I was looking for a solution and crossed yours, very easy and I tested, worked perfect by sites.
    Thanks a lot

  7. I cannot write a single line of code, but just followed your instructions (and worked out how to get a Bing Maps key) and there it was - a Location field added to my sites list. Many thanks!

  8. Hi Borislav. Thanks for the great post.

    I'm hoping you will be able to help me. I'm trying to add a Geolocation field to a list on a SP Online subsite, where the list url is ''

    I have tried all the permutations of the url from through to just the list name - Customer - and each time receive the error message (with the appropriate path name):

    Error: List 'Customer' does not exist at site with URL ''.

    Thanks in advance.

  9. This comment has been removed by the author.

  10. I've been able to add a geolocation field successfully to a list on my SharePoint Online tenant. I've also used a valid Bing maps key. Unfortunately no map is being displayed. When creating a new list item containing the geolocation field, I am not able to select a point from the map. I can only enter a plain text value. Also, when viewing or editing a list item, no map is displayed, just plain text. When I create a map view, just the plain text is displayed. It seems like the geolocation custom field type is not working on my tenant. Any advice?

  11. This looks great, however it doesn't seem to work for me.

    I'm using O365/SP On line, already have a key, have a list, added a script web part to a web part page, added the script then added the html underneath.

    I get the form and enter the information but nothing happens when I click a button and no GeoLocation field appears in my list.

    This may be naïve but am I supposed to place the html before the closing script tag?

    Also, the relative URL I left at "/" because the list is in the sub-sub-site where I'm actually doing all this.


    1. Had the same problem when using Chrome, but then switch to Windows and IE and it worked fine.

  12. Very many thanks!! Worked straight away with our 365/E3/SP online. I'd gotten mostly there but had that annoying 'get credentials, etc' message going across the middle of my maps, which this has now fixed.

  13. As many I will add my thanks.
    Brilliant implementation of original Tobias's post
    Pure teamwork without realising !

    PS: to all = use IE if it doesn't work on Office365.

  14. Excellent post that works on the first try for me. Not often that works but I too, like several others have been scouring the internet searching for something that would work...yes! Awesome.

  15. Hi Borislav, I am running into an error stating "Access denied. You do not have permission to perform this action or access this resource" i am unsure if this is because of the Bing Maps Key or an internal issue, do you have any insight?

  16. Absolutely invaluable! Thank you for taking the time to put this together and post. Very helpful.

  17. One thing I'm having an issue with is when my map is rendered it is showing an overlay message of "The specified credentials are invalid. You can sign up for a free developer account at"... However, I already have an account, this is account is what I used to generate/get the bing maps key.

    Any suggestions on how I can fix this?

  18. I'm using SharePoint Online. This worked for me at first attempt. Thanks for saving my day. This is amazing...!