2. Mark Stokes [MVP]
Red Plane
Microsoft Partner in North West UK
www.redplane.co.uk
@FlyRedPlane
Office 365, SharePoint, Azure, nopCommerce,
Windows 8 Apps, Windows Phone Apps, iOS Apps,
.Net
mark.stokes@redplane.co.uk
@MarkStokes
Interests: Travel, Technology, Photography,
Raspberry Pi, Snowboarding, Wakeboaring, Running,
Tough Mudder, My Dog - Hugo
3. Agenda
What is the Geolocation Field?
Adding Geolocation Field
Bing Maps License
Creating a Map view
Geolocation field example scenarios
4. What is the Geolocation Field?
SharePoint 2013 introduced a new field type named Geolocation that enables you
to annotate SharePoint lists with location information.
In columns of type Geolocation, you can enter location information as a pair of
latitude and longitude coordinates in decimal degrees or retrieve the coordinates
of the user’s current location from the browser if it implements the W3C
Geolocation API.
In the list, SharePoint 2013 displays the location on a map powered by Bing Maps.
A new view named Map View displays the list items as pushpins on a Bing Maps
Ajax control V7 with the list items as cards on the left pane.
Together, the Geolocation field and the Map View enable you to give a spatial
context to any information by integrating data from SharePoint into a mapping
experience, and let your users engage in new ways in your web and mobile apps
and solutions.
5. SP2013 On-Premises – Pre-Requisites
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.
http://msdn.microsoft.com/en-us/library/office/jj163135(v=office.15).aspx
6. Enabling the Geolocation Field
Bing Maps License Key - https://www.bingmapsportal.com
To set the Bing Maps key at the farm level using Windows PowerShell
Set-SPBingMapsKey –BingKey "<Enter a valid Bing Maps key>”
When you use Windows PowerShell, the Bing Maps key can be set only at the
farm level. If you want to set the Bing Maps key at the web level, you can set
the key programmatically.
7. Enabling the Geolocation Field
To set the Bing Maps key at the web level using custom code (C#)
class Program
{
static void Main(string[] args)
{
SetBingMapsKey();
Console.WriteLine("Bing Maps set successfully");
}
static private void SetBingMapsKey()
{
ClientContext context = new ClientContext("<Site Url>");
Web web = context.Web;
web.AllProperties["BING_MAPS_KEY"] = "<Valid Bing Maps Key>”
web.Update();
context.ExecuteQuery();
}
}
8. Enabling the Geolocation Field
To set the Bing Maps key at the web level using custom code (JavaScript)
function SetBingKey() {
clientContext = new SP.ClientContext([Relative Web Address]);
var web = clientContext.get_web();
var webProperties = web.get_allProperties();
webProperties.set_item("BING_MAPS_KEY", “[Enter Bing Maps Key here]”);
web.update();
clientContext.load(web);
clientContext.executeQueryAsync(function (sender, args) {
alert("You have successfully entered BING map key on "+ web.get_title() + " site”);
}, function (sender, args) {
alert("Error: ” + args.get_message());
});
}
9. Map View
A Map View is a SharePoint view that
displays a map (with data obtained from
the Bing Maps service), using longitude and
latitude entries from the Geolocation field
type.
When the Geolocation field type is
available on the SharePoint list, a map view
can be created wither programmatically or
from the SharePoint UI.
In the list, SharePoint 2013 displays the
location on a map powered by Bing Maps.
In additions, a new view type named Map
View displays the list items as pushpins on
a Bing Maps Ajax control V7 with the list
items as card on the left pane.
10. Map View
A map view provides three colors of pushpins, each of which provides a
difference user experience. A pushpin on the map has the same color as the
pushpin of the matching item in the left pane.
Orange Indicates that the Geolocation field for the item is mapped with the Bing
Maps services.
Grey Indicates that the Geolocation field for the item is empty. The item cannot
be mapped with Bing Maps services, so no pushpin for this item appears on the
map.
Blue When a user hovers over a list item, the pushpin color changes from orange
to blue. Both the pushpin in the left pane and the matching pushpin on the map
change color
11. Create a Map View Programmatically
class Program
{
static void Main(string[] args)
{
CreateMapView ();
Console.WriteLine("A map view is created successfully");
}
private static void CreateMapView()
{
// Replace <Site URL> and <List Title> with valid values.
ClientContext context = new ClientContext("<Site Url>");
List oList = context.Web.Lists.GetByTitle("<List Title>");
ViewCreationInformation viewCreationinfo = new ViewCreationInformation();
// Replace <View Name> with the name you want for your map view.
viewCreationinfo.Title = "<View Name>";
viewCreationinfo.ViewTypeKind = ViewType.Html;
View oView = oList.Views.Add(viewCreationinfo);
oView.JSLink = "mapviewtemplate.js";
oView.Update();
context.ExecuteQuery();
}
}
12. Extending the Geoloaction field in a Content
Query Webpart
Shows how to show the Map in a Content Query Web Part
Gives some good examples on changing the format of the Map View, such as
zoom level
http://pafederwitz.wordpress.com/2014/08/19/using-cqwp-to-display-sharepoint-
geolocation-field/
13. Geolocation field example scenarios
Councils - Pot Hole reporting
Construction company / Oil rig – Health and Safety reporting
Logistics – vehicle tracking
Customer location heat maps
Statistical Reporting
Photo location Tagging
Office Locations
Power BI?
15. Geolocation “niggly” bits
Field is not indexed by search
Cannot “paste” list data into Quick Edit mode
Bing Maps only
You have to pay for a Bing Maps license
16. Links
Integrating location and map functionality in SharePoint 2013
http://msdn.microsoft.com/en-us/library/office/jj163135(v=office.15).aspx
Create a map view for the Geolocation field in SharePoint 2013
http://msdn.microsoft.com/en-us/library/office/jj656773(v=office.15).aspx
Getting started with the new Geolocation field in SharePoint 2013
http://zimmergren.net/technical/sp-2013-getting-started-with-the-new-geolocation-field-in-sharepoint-2013
Add a GeoLocation Field to SharePoint Online using PowerShell
http://sharepointryan.com/2013/08/12/add-a-geolocation-field-to-sharepoint-online-using-powershell/
Geolocation field in SharePoint 2013
http://www.sharepoint2013.me/Blog/Post/146/Geolocation-field-in-SharePoint-2013
Using Content Query Web Part to display SharePoint Geolocation Field
http://pafederwitz.wordpress.com/2014/08/19/using-cqwp-to-display-sharepoint-geolocation-field/