How to activate and add the hidden Geolocation (location) column in SharePoint 2013

I was reading through a bunch of Technet articles today and I found a few things that I had never seen before for SharePoint 2013.  One of those things was the hidden Geolocation column.

 IC592039

 

This column allows for latitude and longitude coordinates to be stored in a location column type within SharePoint.  This can then be coupled with Bing maps and you can create map views natively from within SharePoint from the create view menu!  This also allows for geotags from within photos, from mobile devices, laptops, PC’s, and other devices that have access to your SharePoint environment to be able to automatically fill this field from the GPS sensor from whatever device is editing/updating/accessing that specific content.  

IC616117     IC616119

Caveats

  1. An MSI package named SQLSysClrTypes.msi must be installed on every SharePoint front-end web server to view the geolocation field value or data in a list. This package installs components that implement the new geometry, geography, and hierarchy ID types in SQL Server 2008. By default, this file is installed for SharePoint Online. However, it is not for an on-premises deployment of SharePoint Server 2013. You must be a member of the Farm Administrators group to perform this operation. To download SQLSysClrTypes.msi, see Microsoft SQL Server 2008 R2 SP1 Feature Pack for SQL Server 2008, or Microsoft SQL Server 2012 Feature Packfor SQL Server 2012 in the Microsoft Download Center. Note: By default this already installed on SharePoint Online / Office 365.
  2. You must create and activate a bing maps key at the farm or site level within your environment:
    1. To activate it at the farm level open a SharePoint Management Shell window as an administrator and run the following script.  You must run as either the farm account or be a member of the farm administrators group, and have the  db_owner fixed security role on all db’s to updated and also have the securityadmin fixed security role at the server in SQL server, and finally be in the administrators group on the server your running the cmdlet from.
      Set-SPBingMapsKey -BingKey <Bing Maps Key>

      to verify it took run

      get-SPBingMapsKey
    2. To activate it at the site level open a SharePoint Management Shell window as an administrator and run the following script:
      $ServerName = "<SharePoint Server>"
      $site = new-object Microsoft.SharePoint.SPSite($ServerName)
      $web = $site.rootweb
      $web.AllProperties["BING_MAPS_KEY"] = "<Your Bing Maps key>"
      $web.Update()
  3. To add the column to a list it must be done programatically.
    1.  Create a visual studio console application project.
    2. Add a reference to both Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll
    3. add using Microsoft.SharePoint.Client to your using directives.
    4. Add and in the main method add the following:
      class Program
          {
              static void Main(string[] args)
              {
                  AddGeolocationField();
                  Console.WriteLine("Location field added successfully");
              }
              private static void AddGeolocationField()
              { 
               // Replace site URL and List Title with Valid values.
                  ClientContext context = new ClientContext("<Site Url>"); 
                  List oList = context.Web.Lists.GetByTitle("<List Title>");
                  oList.Fields.AddFieldAsXml("<Field Type='Geolocation' DisplayName='Location'/>",true, AddFieldOptions.AddToAllContentTypes);                                        
                  oList.Update();
                  context.ExecuteQuery();
              } 
          }
    5. You can now view and edit that column from the SharePoint UI.

Here are the appropriate articles you will need to get started:

Blogs:

Microsoft Articles:

Integrating location and map functionality

Use location for mobile applications

Tagged , , , , , , , , ,

Leave a Reply