How to use Geo Location Field in SharePoint Online with Bing Maps

Sriram Varadarajan
 
Solution Architect
June 4, 2016
 
Rate this article
 
Views
17818

It’s been a while since Microsoft introduced Geolocation location datatype in SQL but it’s wasn’t rolled out to SharePoint immediately. Microsoft has addressed this demand in SharePoint 2013 (though not that straight forward) but still you can use it.

What is Geolocation means to us

In columns of type Geolocation, you can enter location information as a pair of latitude and longitude coordinates and retrieve those co-ordinates and display it in a Bing Map (Or any equivalent API).

How to add a Geolocation Column: I’m pretty sure this would be the next question, how to add this column as you don’t find this column type either in site/list column.

The Geolocation column is not available in SharePoint lists for users, by default. To add the column to a SharePoint list, you need to write code.

Script:

 $WebUrl = "Site collection URL"
 $EmailAddress = "User ID"
 $Context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl)
 $Credentials = Get-Credential -UserName $EmailAddress -Message "Please enter your Office 365 Password"
 $Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($EmailAddress,$Credentials.Password)
 $List = $Context.Web.Lists.GetByTitle("List Name")
 $FieldXml = "<Field Type='Geolocation' DisplayName='Demo locatie'/>"
 $Option=[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView
 $List.Fields.AddFieldAsXml($fieldxml,$true,$option)
 $Context.Load($list)
 $Context.ExecuteQuery()
 $Context.Dispose() 
 

How to display this column in Bing Map

1. List Data in Bing Map is a SharePoint online app that is used for visualizing the data from SharePoint list and it’s a free APP

Follow the steps to add this APP to you site

Navigate to your target site and select the gear in the top right corner: Please refer to this article to understand the access and permission required to perform the below activity

clip_image002

Select Add an APP from the list options.

a.

clip_image004

Select SharePoint Store from the list of options displayed on the left side of the page.

b. In the SharePoint Store site, search for the APP List data in Bing Map in the search BOX available in the top right corner.

clip_image006

clip_image008

c. Select the APP and Click REQUEST IT. (Since this APP needs high privilege this can’t be directly added to the site, this needs to be approved by the store admin to get this added to your site)

d. Once approved this APP would get added to your site.

Next step is to add this APP to your page

Please follow the below steps:

Step 1

clip_image009

clip_image011

After successfully installing the Bing Map App, you may use it right away. The app is ideal for the visualization of SharePoint list data. You will need a SharePoint list with at least two data columns – latitude and longitude. To fully visualize all your contents, you will need additional columns containing more information. In addition, a valid Bing Map Key is required; without it you won’t be able to use the app. To embed the app part in a website, open the target website in its editing mode. Enable the tab "INSERT". In the ribbon, click the button "App Part" to view the available app parts in list form. Select the app part dev-sky – List data in Bing Map. Click ADD on the right to install the app part on the website. To configure the part and its user settings, set the app part to its editing mode (see left image). Open the context menu of the app part to enable the menu item EDIT WEB PART. Then configure the part itself following Step 2 below.

Step 2

clip_image013

Enter a valid Bing Map Key into the upper text field.

WARNING: You can not use this app without a valid key!

Select the SharePoint list containing the data for visualization from the selection window below. A new list will display all available list view settings. Select the desired view. The selection windows below will display all available columns in the selected view format. Select the columns according to their contents. After entering all information, click the lower button to save the settings. WARNING: Saving the web part settings only, will not save all configurations made.

Control behaviour via List settings

You might need to adjust the size of the map’s text fields according to their content length. To do so, the selected view setting must have the two fields: BingMapInfoHeight and BingMapInfoWidth. Both fields must be set to a NUMBER value. Here, you can enter the size for each text field. Leave blank, if the size of your text fields shall remain unchanged.

TIP: For these settings to be recognized, enable the option "Pop-up Dimensions" under Web Parts settings.

2. User should generate the Bing map key and add them to the configuration list on the same SharePoint site (one time activity)

a. Creating BING KEY

b. When you use any Bing Maps API with a Bing Maps Key (you must have a Bing Maps Account), transactions are recorded. Transactions track API usage and can be billable or non-billable.

c. The Bing Maps API usage tracking doesn’t save any of the site/user related information.

d. To understand more on billable and non-billable service, please refer to

With this we should able to see the Bing Map actually functioning.

Category : Office 365, SharePoint

Author Info

Sriram Varadarajan
 
Solution Architect
 
Rate this article
 
Sriram is a Technology Evangelist with 15+ years experience in Microsoft Technologies. He is an enterprise architect working for large pharmaceutical organization which has presence globally with largest Microsoft implementation ...read more
 

Leave a comment