Tip of the day for Windows Phone developers - the Map control is not always necessary

DZone 's Guide to

Tip of the day for Windows Phone developers - the Map control is not always necessary

· Mobile Zone ·
Free Resource

If you look in the Windows Phone Marketplace, you will notice that there is a plethora of applications that are using device-based location and maps. There is the Map control that facilitates the use and customization of user's surroundings, but what some developers don't know is that for some static content the Map control is overkill.

Instead, it is worth looking at the open Bing Maps API that allows the developer to access location tiles in different formats and sizes, as long as the longitude and the latitude of a searched point are known.

For example, here is a service request URL that will return a location tile:


Notice how I am passing the latitude and the longitude via the c parameter. w and h parameters determine the width and height of the returned image. b is the appearance descriptor. In this case, there is a device.mobile option that will increase the frequency of different location indicators (e.g. street names or highway numbers).

The z parameter is the zoom factor. This value has the range: 1 to 21 (21 being the highest). Going beyond this range will cause a Bad Request error.

But I don't want the logo on the map...

For whatever reason you might need to remove the logos from the tile (e.g. taking too much space), you can do this through the same URL parameters. To remove the Bing logo, use the logo=no pair. To remove the NAVTEQ reference, use the da=n pair. Compare the two images above to see what I am talking about.

How can I get the lat/lon values?

The coordinates used in the service request are used in the same format as the latitude and longitude returned by GeoCoordinateWatcher:

GeoCoordinateWatcher watcher;
public MainPage()

    watcher = new GeoCoordinateWatcher();
    watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);

void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
    Debug.WriteLine(e.Position.Location.Latitude + " " + e.Position.Location.Longitude);

These service endpoints can be extremely useful for what Windows Phone does best - implement live tiles.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}