Chapter 3. Using Maps in your Windows Phone App

Any book covering location is not complete without mentioning maps. Maps provide a great visual experience for location-based services. Maps are now a default feature on most smartphones as they provide a good graphical overview of information (usually geotagged data) around the user's location.

With custom pin markers and directions, maps also help users navigate to their destination easily. Most importantly maps give the user a feeling that "This place is around the next block, north from where I am standing," so decision-making happens quickly for the user.

In this chapter we shall cover the following topics:

  • Understanding map geometry
  • Overview of Windows Bing Maps Silverlight Control
  • Using maps in your Windows Phone application — Hello Maps
  • Using pushpins with maps
  • Custom map pushpins
  • Handling pushpin events
  • Working with Bing Maps geocoding and reverse geocoding services
  • Overview of Launchers and Choosers
  • Using directions with Bing Maps directions task
  • Performing local searches with BingMapsTask

Understanding map geometry

Windows Phone 7.5 supports two methods of map display in your mobile app:

  • Bing Maps Silverlight Control for Windows Phone
  • Bing Maps task Launcher

Before we delve into the methods, actions, and tasks of the Windows Phone Bing Maps Silverlight Control or the Bing Maps task Launcher, it is a good idea to get acquainted with the background of map geometry and how it works for Bing Maps. If you have a background in Computer Science, then you would be aware of keywords such as projection, trajectory, coordinate systems, raster and scalable graphics. If you are not from a Computer Science background, then a basic understanding of the Bing Maps API can be found at http://msdn.microsoft.com/en-us/library/ff428643.aspx. This should be good to get you started with Bing Maps.

Bing Maps uses the Mercator projection model of converting the Earth's sphere into a corresponding flat surface, grid-based, parallel map. In such a projection the longitude lines are parallel, and hence the land mass further from the equator tends to be distorted. However, the Mercator projection works well for navigational purposes, and therefore, despite the drawbacks, it is still used today.

The Mercator projection offers two compelling advantages:

  • The map scale is constant around any position.
  • Mercator projection is a cylindrical projection. North and south are straight up and down, while west and east are always left and right respectively. (This helps in keeping track of your course in navigation.)

The following diagrams should give you a good idea about the Mercator projection:

Understanding map geometry

Note

Earth's surface as a sphere diagram courtesy Michael Pidwirny from http://www.eoearth.org/article/Maps and http://www.physicalgeography.net/fundamentals/2a.html.

Understanding map geometry

Note

Mercator projection of the Earth's surface diagram courtesy Michael Pidwirny from http://www.eoearth.org/article/Maps and http://www.physicalgeography.net/fundamentals/2a.html.

The world map is pre-rendered at many different levels of detail and cut into tiles for quick retrieval. When you zoom in or zoom out on your Bing Maps, it is nothing but loading different tiles at different levels. To read more about the Bing Maps Tile System please see the following MSDN link:

http://msdn.microsoft.com/en-us/library/bb259689.aspx

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.255.225