Book Image

Windows Phone 7.5: Building Location-aware Applications

Book Image

Windows Phone 7.5: Building Location-aware Applications

Overview of this book

Windows Phone 7.5 has met with some great initial reviews from all mobile critics. It is poised to be the '3rd' eco-system for mobile, joining Apple's iOS and Google's Android platform. With Microsoft and Nokia working on multiple devices based on Windows Phone, the platform is a no-brainer enterprise success. Microsoft Office, Email, Skype and a fresh new mobile operating system has been a great champion of a cause for both Microsoft and Nokia. "Windows Phone 7.5: Building Location-aware Applications" will teach you to divein to the new Windows Phone Experience. No more 600 page bibles - just the right mix of text and lots of code to get you started!"Windows Phone 7.5: Building Location-aware Applications" covers location based services and maps, and focuses on methods of location detection and maps. Powered with this information, two real-world applications are covered. In short, this is a concise book on building location aware apps for Windows Phone.
Table of Contents (11 chapters)
Windows Phone 7.5: Building Location-aware Applications
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Life without GPS: Bing Maps API


Bing Maps provides a REST API for creating a static map with pushpins, geocoding an address, and creating routes. There are a plethora of options available for Microsoft lovers (http://msdn.microsoft.com/en-us/library/dd877180.aspx) ranging from Ajax controls to iOS controls for using Bing Maps in your application. We will, however, use the REST API to determine the user's location (when Wi-Fi and cellular radio is not available to determine location).

Specifically we will use the Bing Maps API to convert a user address into location; this process is known as geocoding, as described earlier. Bing Maps uses these coordinates to plot the locations on a map. The Bing Maps API provides an option for both geocoding and reverse geocoding.

To illustrate a simple REST API call from the Bing Maps API that finds location by a given address, see http://msdn.microsoft.com/en-us/library/ff701715.aspx. The Geocoding API is consumed by the following API call:

http://dev.virtualearth.net/REST/v1/Locations/US/adminDistrict/postalCode/locality/addressLine?includeNeighborhood=includeNeighborhood&key=BingMapsKey, where the output can be either JSON or XML, and the parameters can be either of the following:

Parameters

Description

adminDistrict

Typically a US state.

postalCode

US zip code.

Locality

City name.

addressLine

Street address.

includeNeighborhood

For including neighborhood data in response. This value can be either 0 or 1.

BingMapsKey

Key obtained from https://www.bingmapsportal.com/.

An example geocoding request for Microsoft Corporation office at Mountain View, San Francisco, CA, USA is constructed as:

http://dev.virtualearth.net/REST/v1/Locations/US/CA/94043/San Francisco/1065 La Avenida St?o=xml&key=xxxxxxxxxxxxxxxx, where xxxxxxxxxxxxxxxx is the Bing Maps API key you obtained from https://www.bingmapsportal.com/. This API call returns the following results:

Our interest lies is in the<Latitude> and<Longitude> XML nodes, which hold the location value for the address we specified. If you do not have the exact address, you can use the Find a location by Query API call of the Bing Maps API, where the input can be any query string. Depending upon your app's targeted region, construct the right REST call. As they say, "Read the documentation carefully".