How to get the geolocation column in SPO

If you wanted to add a GeoLocation Column in your SPO tenant, you have to use the following XML:

“<Field Type=’Geolocation’ DisplayName=’Geolocation’ Name=’geolocation’ />”
The important part here is the addition of the
Name property in the field definition.
The complete script to add it to your site is:

$cred =get-credential
Connect-SPOnline -Url https://yourtenantname/sites/organization -Credentials $cred
$list = Get-SPOList -Identity Locations
$FieldXml = <Field Type='Geolocation' DisplayName='Geolocation' Name='geolocation' />
Add-SPOFieldFromXml -FieldXml $FieldXml -List $list

For this script I used the
OfficeDevPnP PowerShell CmdLets

Like the procedure OnPrem, we need to access to http://www.bingmapsportal.com/ to get the key. The next lines are copied from a previous post:

We need to do additional steps, first of them, it’s that we need to have a Bing Maps account. It is possible to obtain a free account as a Developer

3g

It will be necessary to complete the form, and once it has been click on submit, we will receive on the screen the Bing Keys.

 

After getting the key you can set it to the web properties of the site where you use the geolocation field. This can also be done with one of the Office Dev PnP PowerShell commands: “Set-SPOPropertyBagValue”

$web = Get-SPOWeb
Set-SPOPropertyBagValue -Key “BING_MAPS_KEY” -Value “BingValueKey” -Web $web

That’s all, now you have a fully working geolocation field in your list.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s