Adding mapping features to your Windows 8 | Windows Phone app

Today almost every device has GPS sensor onboard and application could be much more useful if you provide mapping features for users. Any search for places, people, goods could be better if user could see results on the map, and even build a route there.
Imaging the simple scenario where you want to display search result (e.g. places nearby) on the map:

Places Nearby -> Places on the map transition

wguru windows8 app nearby list

gmaps windows8 app activated - wguru nearby list
 

Standard approach

What is the usual way to accomplish this task? Here steps:

  • First, you have to integrate Bing Maps control into your Windows 8 / Windows Phone app. You have also generate unique key to use the control and associate with your account/application
  • Then you need to write some code to draw pushpins, bind them to data and control active/inactive pushpin state
  • Then you need to integrate route web services to give user ability to build routes to displayed pushpins
  • Finally you have to handle navigation between new map page and other parts of your application

Any alternatives?

gMaps team happy to answer ‘YES’ to this question! Mapping apps for both Windows Phone and Windows 8 are already in the store and both could be easily leveraged by your apps. All you need to do is to install specific Nuget package and write several lines of code. Let us return to our scenario above and activate gMaps application to show places nearby for wGuru app:
 

    1. Install nuget package

We have two separate packages for Windows Phone and Windows 8 platforms. To install package open package manager (References->Manage Nuget Packages) or just execute the following command (for WP version use another package name) at Package Manager Console (View->Other Windows->Package Manager Console):

PM> Install-Package gMaps.WP.Tasks

    2. Prepare data

We have list of places nearby with known Location and place Name. Let us call it SpotsNearby
var pushpinsQ = from s in SpotsNearby
select new PushpinPoint(
s.Location.Latitude,
s.Location.Longitude,
s.Name);
var pushpins = pushpinsQ.ToList();

    3. Use gMaps OpenMapTask to activate mapping application

await new OpenMapTask("wGuru", pushpins).Show();

That is it. You have mapping functions in three simple steps.

gMaps tasks API is identical for both platforms. This is initial API version and it implements MAPS protocol scheme defined by Microsoft. That means you can contract MAPS Uri by yourself (even without tasks usage) to activate any mapping application that supports this scheme. We are still working under Tasks API improvements so fill free to suggest yours.

Links

Nuget gMaps Tasks for Windows Phone

Nuget gMaps Tasks for Windows 8

gMaps Activation Sample (Source codes)

MAPS protocol scheme

Apps:

wGuru for Windows 8

gMaps for Windows 8

gMaps for WindowsPhone

We appreciate your feedback and looking forward to hear your stories of mapping functions integration. Enjoy!