Chapter 18. Incorporating Map-Based Positioning

,

In This Chapter

Image Procuring a map API key pair

Image Switching between map modes (for example, aerial and road) using a viewmodel property

Image Searching for and displaying routes on a map

Image Panning and zooming the map control

Image Using map layers to display custom objects

Image Tracking geographic location on a map

Image Controlling the VisualStateManager via a ViewModel property

Image Allowing the user to download maps using the MapDownloaderTask class


Mapping capabilities are now an expected part of just about every smartphone, and, as you might expect, Windows Phone has a rich built-in Maps application that leverages Nokia mapping data as its principal mapping service. In addition to the built-in Maps app, the Windows Phone SDK includes a Map control, enabling you to incorporate mapping features into your own apps.

The new Windows Phone 8 Map control replaces the earlier Bing Maps control and allows the user to download maps from the built-in Maps app so that map data is available even when the phone does not have a data connection. The Bing Maps control is still supported in Windows Phone 8, but has been deprecated.

This chapter begins with an overview of the Map control and walks through the creation of a Map API key. You see how to programmatically manipulate the map view—in particular, how to pan and zoom, as well as how to adjust the pitch and heading of the map view. You look at using the new Geolocator API to pinpoint the phone’s current location on the map.

The chapter then continues on from the previous chapter. You see how to track the phone’s location on a map using the Geolocator class and the custom mock IGeoLocator implementation.

The chapter then examines the Route Query API and how to locate a route between two user-provided addresses. The chapter illustrates how to coordinate multiple asynchronous operations and how to create an asynchronous method using a task completion source. You also look at hiding and revealing page elements using a viewmodel’s VisualState property in conjunction with an attached property and a custom VisualStateUtility class.

Finally, the chapter demonstrates how to present a list of itinerary items as an expandable list. You look at allowing the user to download maps for offline viewing, and at launching the built-in Maps app using the launcher API.

The majority of the source code for this chapter is located in the Mapping directory of the WPUnleashed.Examples project in the Vaughan.WPUnleashed solution, in the downloadable sample code.

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

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