Thursday, 10 November 2016

How to add a Geolocation field to SharePoint 2016 lists using PowerShell

Today we are going to create Geolocation Field on SharePoint 2016 using PowerShell command. Geolocation Map and field on SharePoint list allow us to see any location on Map View. If we have list with lot of Maps we need to see those on Map view we need Geolocation Field and Map view which we will be disappear default in any version of SharePoint.

So we need to run few of command to enable and create Geolocation automatic on SharePoint List.
We need to follow below steps:
  • Create a new list on SharePoint 2016 site.
  • Open SharePoint 2016 Management shell and run below command with some modification as mentioned in Screen shot.

$web = Get-SPWeb http://intranet.team.com //Your Site name
$list = $web.Lists["Contacts"] //List Name
$list.Fields.AddFieldAsXml("<Field Type='Geolocation' DisplayName='Location'/>", $true, [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
Set-SPBingMapsKey -BingKey “AjtUzWJBHlI3Ma_Ke6Qv2fGRXEs0ua5hUQi54ECwfXTiWsitll4AkETZDihjcfeI”
  • Now go back to list and click on the same and verify the field has been created.
  • Now verify the Map view has been created, click on new View and verified the same, now we need to create new View as well.

  • Create

No comments:

Post a Comment