Add Geolocation Column to SharePoint

Unfortunately, the new “Geolocation” column in SP2013 doesn’t come ‘turned on’ by default.

I was able to easily add it as a ‘site column’ – and then can add to any list.

  • Open Visual Studio project
  • Create a C# console app
  • Add a reference to the following :
    • Microsoft.SharePoint.Client
    • Microsoft.SharePoint.Client.Runtime
  • Include the following code :

ClientContext context = new ClientContext(“https//server/site”);
Web web = context.Web;
context.ExecuteQuery();

var newField = web.Fields.AddFieldAsXml(“<Field Type=’Geolocation’ DisplayName=’Map GeoLocation’/>”, false, AddFieldOptions.DefaultValue);

context.ExecuteQuery();

After executing the project, you should be able to go back to SharePoint – and do the following ;

Edit properties of a list, and click “add from existing site columns” :

image
Choose the new column :

image

And there it is :

image

That’s about it – too easy, eh !?

** The same code should work for Office 365 – I haven’t tried it yet though – will update soon…

Advertisements

One thought on “Add Geolocation Column to SharePoint

  1. Hi Chris!
    It looks interesting, but what is the result, can You show screenshot please? What is this Geolocation Column in general and what is the profit of using it.

    Like

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s