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
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)
Apps:
We appreciate your feedback and looking forward to hear your stories of mapping functions integration. Enjoy!
[…] Read More >> […]
Can I use it as a location picker in windows 8? I mean in my app user should be able to specify some custom locations and it would be nice to do it using gMaps. Or it’s just for displaying data?
This is really nice feature. Unfortunately the activation protocol is one way and there is no way to create custom chooser task right now. We will keep it in mind. Hope with Windows 8 development this will be possible.
I am loving this app and planning to upgrade to the paid version. I was wondering if you were going to add the ability to sign into Google accounts.
I would like to access my saved maps, as I often use them when traveling to find the places of interest I’ve saved. If not, is there an alternate way to export those lists (KML file) into my GMap on my phone? (I’m willing to pay an extra premium for that, as I actually like this app better than the Google Maps app on Droid.)
Thanks for your feedback! We appreciate it. For now we have ability to import favorites from google account. Could you please clarify scenario of importing/exporting KML files?
As an example, I went to New York City recently. I created a Google Map before I went. (https://maps.google.com/maps/ms?msid=213921256110106287748.0004cd4c5b954ac669333&msa=0)
On my Android phone with Google Maps I was able to access & edit that map right from the phone, but I created it, for the most part, on my computer.
If the ability to import favorites is already there, I haven’t found it in the free version. (I haven’t bought the paid version yet.)
I don’t exactly how importing KML files would work – it seems like accessing the current version (and being able to edit it on the fly) from a Google account would be preferable.
Regarding opening maps as a location picker you may pass additional argument – “uri to launch when picked” it should work both in WP and Win8 🙂
And that “back” uri could have selected GPS position… Interesting approach!
This is really good integration point with mapping application.
We will put this feature in out development pipeline.
Thanks for great proposal!
Hi,
I am developing an application for window embedded compact 7 based device and within application I am using Gmap.NET Control for Map and Navigation Route.
Its working fine at my end but the same application does not run properly when it is run on the same device in another country. It loads the Map but Navigation Route is always null.
It did work initially but is not working now.
Could you please advise about the possible solution.
Hi!
Regarding your question, it looks like you are using another control (http://greatmaps.codeplex.com/) which we do not have any relation to.
I would suggest you to contact GreatMaps team and also post your question in discussions http://greatmaps.codeplex.com/discussions
When posting a question, please include source code example or error details.
Alex.