Sunday 2 November 2014

Use Geolocation column to show map view within lists or libraries in sharepoint online


One of the best feature which i learned recent times is Geo-location field in Sharepoint online even we can do it in on-promises also
In-order to enable Geo-location field we need Share point online management shell even we can do it with coding also i tried with powershell. So u can download management shell from below link

https://support.office.com/en-us/article/Set-up-the-SharePoint-Online-Management-Shell-environment-7b931221-63e2-45cc-9ebc-30e042f17e2c?ui=en-US&rs=en-US&ad=US

after downloading the management shell open it from start with administrator privileges. and type the below command to connect with online
Connect-SPOService -Url https://example-admin.sharepoint.com -credential demo@example.onmicrosoft.com

it will ask password just type your online password





and type below powershell commands by replacing list and website url ,

$WebUrl = ‘https://example.sharepoint.com/sites/dev1
$EmailAddress = “demo@example.onmicrosoft.com
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl)
$Credentials = Get-Credential -UserName $EmailAddress -Message “Please enter your Office 365 Password”
$Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($EmailAddress,$Credentials.Password)
$List = $Context.Web.Lists.GetByTitle(“replaced with your list“)
$FieldXml = “<Field Type=’Geolocation’ DisplayName=’Location‘/>”
$Option=[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView
$List.Fields.AddFieldAsXml($fieldxml,$true,$option)
$Context.Load($List)
$Context.ExecuteQuery()
$Context.Dispose()

if allow go well you will see the map view under views of specified list as shown below
you will see the office location column in list you specified

now we need to get the bing map key for displaying the maps you can get from below link
     http://www.bingmapsportal.com/
now update the above script with map key as shown below
$web = $Context.Web
$web.AllProperties["BING_MAPS_KEY"] ="insert your bing map key here
$web.Update()
$context.ExecuteQuery()
$Context.Dispose()

now you will see below screen in list
in map view we can see the clear view as shown below




3 comments:

  1. nice post helped me alot

    ReplyDelete
  2. I've learn several good stuff here. Definitely worth bookmarking for revisiting. I surprise how so much effort you set to make this type of wonderful informative website.

    ReplyDelete
  3. Hiya! I know this is kinda off topic but I'd figured I'd ask. Would you be interested in trading links or maybe guest writing a blog post or vice-versa? My website addresses a lot of the same topics as yours and I feel we could greatly benefit from each other. If you might be interested feel free to shoot me an email. I look forward to hearing from you! Great blog by the way!

    ReplyDelete