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:
- Register for a Bing map key
- Set Bing map key in SharePoint
- Add GeoLocation column to SharePoint site/list Programmatically.
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.
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 a Geolocation column to a 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!
and the Geolocation field in action!
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”
and the result goes here:
To add Geo-location column to SharePoint Online, refer: How to Add Geo-location (Bing Maps) Field to SharePoint Online List using PowerShell?