Thursday, November 21, 2013

Bing Maps with GeoLocation Column in SharePoint 2013

SharePoint 2013 introduced a new functionality called "Geolocation" as a Field type to enable location based data in SharePoint lists. So with GeoLocation field, we can bring "Map" experience to the users.  Geolocation Field type is not enabled by default. We have to do few configurations to make it available in SharePoint 2013.

Here are the steps in summary to enable Geolocation field in SharePoint 2013:

  1. Register for a Bing map key
  2. Set Bing map key in SharePoint
  3. Add GeoLocation column to SharePoint  site/list Programmatically.
Pre-requisites: You need to have SQLSysClrTypes.msi installed on every SharePoint front-end web server for SharePoint 2013 GeoLocation-Bing Map functionality. So, Download and install "SqlSYsCLRTypes.msi' from: http://www.microsoft.com/en-us/download/details.aspx?id=29065 (For SQL Server 2012.)


Step 1: Get a Bing map key Obtain a Bing map key by registering at: https://www.bingmapsportal.com. In my case, Here is what I've created by clicking "Create or View Keys".
On clicking Submit, you'll get a message "Key created successfully" with Keys listed below the form.
sharepoint 2013 geolocation field


Step 2: Set Bing Map Key in SharePoint 2013
Login to your SharePoint Server, From SharePoint Management PowerShell, Enter:

Set-SPBingMapsKey –BingKey "<Bing Maps key obtained>"

This sets Bing API Key at the farm level. Its also possible to set Bing map key at Web Application Level.

Step 3: Add GeoLocation Field to SharePoint Site/List
Unfortunately, There is no UI way to add Geolocation column to SharePoint site or List! So, Lets do it programmatically using PowerShell.
Add-PSSnapin Microsoft.SharePOint.PowerShell

#SharePoint Site URL to add Geolocation field
$webURL = "http://sharepoint.crescent.com/"

#Field definition for Geolocation  
$fieldXml = "<Field Type='Geolocation' DisplayName='Location' />"

#Get the Web 
$web = Get-SPWeb $webURL

#Add field to the Web
$web.Fields.AddFieldAsXml($fieldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::Default)
This adds "Location" field to the provided SharePoint web. You can Navigate to List settings >> Add from Existing columns and then Select "Location" column under Custom columns group.

Its also possible to add GeoLocation column directly to the SharePoint list. Here is the PowerShell script:
Add-PSSnapin Microsoft.SharePOint.PowerShell

#SharePoint Site URL and List name parameters.
$webURL = "http://sharepoint.crescent.com/"
$ListName = "Project List"

#Field definition for Geolocation  
$fieldXml = "<Field Type='Geolocation' DisplayName='Project Location' />"

#Get the Web & List  
$web = Get-SPWeb $webURL
$list = $web.Lists[$ListName]

#Add the Field to List  
$list.Fields.AddFieldAsXml($fieldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::Default)
$list.Update()

#or use: $FieldType = [Microsoft.SharePoint.SPFieldType]::Geolocation
#$List.Fields.Add($columnName, $FieldType, $false)

Set GeoLocation column Value:
Now, You can enter locations either by Providing Latitude-Longitude coordinates or based on current location. On clicking "Use My Location" link, SharePoint automatically sets the location based on your IP!
sharepoint 2013 geolocation column
 and the Geolocation field in action!
GeoLocation Column in SharePoint 2013

Map View
Geolocation functionality also provides an another feature: Map View, which gives map layout for the locations tagged. Just create a new view for your list/library >> Choose "Map View"
How to Create Map View in SharePoint 2013

and the result goes here:



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...