SharePoint 2013 introduces a new built in functionality to show maps directly within a list or library using a new field type named Geolocation. The new 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. I created a map to display my team members and the map where they are as below.
1. Install "Microsoft SQL Server 2012 Feature Pack" on every SharePoint front-end web server to view
the Geolocation field value or data in a list. To download SQLSysClrTypes.msi, see Microsoft SQL Server 2008 R2 SP1 Feature Pack for SQL
Server 2008, or Microsoft SQL Server 2012 Feature Pack for SQL Server 2012
in the Microsoft Download Center.
2. Download a valid Bing Maps key, which you can obtain from
the Bing Maps Account
Center. You need this key to display Bing map.
3. Set the Bing Maps key at the web and farm level if Get-SPBingMapsKey does not return the value. Here is the command to set on farm level. You could use API to set on web level.
Set-SPBingMapsKey –BingKey “<Enter a valid Bing Maps key>”
4. Add a GeoLocation column to a list programmatically using the following code sample. At this time there is no UI you could add the GeoLocation column!!!
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();
}
}
You could add this to site column to a site collection so you can use it in any list on the site. Please note you need to enable "Allow management of content types" for the list before running the code above. Go to "List Settings"->"Advanced settings" and enable "Allow management of content types". Otherwise, the code above will fail.
5. Get Longitude and Latitude of the location from Bing maps and enter to the list. You could refer the video to get these.
Now you have the maps in place and I noticed a bug that the Bing map sometimes ass in the picture above. I have added my location as San Diego, CA USA. But it always display my location as China and I'm not able to fix the problem.
There are many other new features 2103 supports maps including BI Excel Power View. You may take a look of SharePoint BI solutions.
No comments:
Post a Comment