Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Windows Phone 7.5: Building Location-aware Applications

You're reading from   Windows Phone 7.5: Building Location-aware Applications Build your first Windows Phone application with Location and Maps with this book and ebook.

Arrow left icon
Product type Paperback
Published in Jul 2012
Publisher Packt
ISBN-13 9781849687249
Length 148 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Windows Phone 7.5: Building Location-aware Applications
Credits
About the Author
About the Reviewers
1. www.PacktPub.com
2. Preface
1. The Location-based World FREE CHAPTER 2. Using Location in Windows Phone 7.5 3. Using Maps in your Windows Phone App 4. Events App - PacktEvents 5. Location-aware News App — PacktNews

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".

You have been reading a chapter from
Windows Phone 7.5: Building Location-aware Applications
Published in: Jul 2012
Publisher: Packt
ISBN-13: 9781849687249
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image