Share via


Powershell to add a geolocation site column in SharePoint 2013

SharePoint 2013 introduces a new Geolocation field to help us integrate geolocation information and maps into our applications.

Here is a great introduction to it:

https://msdn.microsoft.com/en-us/library/jj163135(v=office.15).aspx

Unfortunately, we cannot create a new column based on the new geolocation type from SharePoint user interface. It has to be done from powershell or programmatically.

The powershell script below will create a geolocation site column for a site:

$weburl = "https://somesite"

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

$web = get-spweb $weburl

$field = $web.Fields.AddFieldAsXml($fieldXml)

$web.Update()