Skip to Content
Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4
book

Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4

by Chris G. Williams, George W. Clingerman
February 2011
Beginner to intermediate content levelBeginner to intermediate
552 pages
12h 40m
English
Wrox
Content preview from Professional Windows® Phone 7 Game Development: Creating Games using XNA Game Studio 4

Chapter 13. Dude, Where's My Car?

WHAT'S IN THIS CHAPTER?

  • Understanding the Location API

  • How to look up your current location with the GeoCoordinateWatcher class

  • How to use the CivicAddressResolver class

Windows Phone 7 offers a Location API that allows you to determine your location in multiple ways, including GPS, WiFi lookup, and cell tower triangulation. This chapter prepares you for using that service.

UNDERSTANDING AND ACCESSING THE LOCATION API

The Location API is provided so that you don't have to worry about customizing your game or application for specific hardware configurations. This includes not needing to worry about the specifics of how the data is acquired (via GPS, cell tower, and so on).

Everything you need to access your phone's location is stored within the System.Device .Location namespace. You will be concerned with three types of data in this chapter: CivicAddress, GeoCoordinate, and GeoPosition.

Unfortunately, if you don't have a phone, you'll be unable to test all the examples presented in this chapter as intended. The Emulator has no means of acquiring actual GPS data.

BEST PRACTICES FOR USING LOCATION SERVICES

In this chapter, you will learn several different ways to interact with the Location API inside your game or app. What follows are some best practices when dealing with location data.

Asking Permission

When using any of the methods presented in this chapter in your app or game, you must ask the user's permission to get his or her location. Failure to do so can ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XNA Game Studio 4.0 Programming: Developing for Windows® Phone 7 and Xbox 360®

XNA Game Studio 4.0 Programming: Developing for Windows® Phone 7 and Xbox 360®

Tom Miller, Dean Johnson

Publisher Resources

ISBN: 9780470922446Purchase book