CHAPTER 8 EXERCISE SOLUTIONS

Exercise 1 Solution

The most appropriate answer is b. Answer c is also correct, but it's far too narrow a definition because web services can do much more.

Exercise 2 Solution

To start with, you would use location services only if requested, perhaps with a “near me” link. You might provide other options, such as letting users choose from a list of locations. You would then perform a one-shot location detection to locate nearby restaurants, and then you'd shut off the location service again. Default accuracy would be enough for this. If you were to also provide route-finding functionality to help users find restaurants, you might use high accuracy and keep the location service running while the user gets to the location.

Exercise 3 Solution

You use the GeoCoordinateWatcher class for obtaining location information.

Exercise 4 Solution

You use the GeoCoordinate.GetDistanceTo() method, which gets the distance between two GeoCoordinate instances, in meters.

Exercise 5 Solution

Before using the Bing Maps Silverlight control, you must obtain a usage key.

Exercise 6 Solution

You use the Scale class, which you would include in XAML as follows:

<m:Map CredentialsProvider=“<My Key>”
  <m:Map.Children>
    <o:Scale />
  </m:Map.Children>
</m:Map>

This code assumes the following namespaces:

xmlsn:m=“clr-namespace:Microsoft.Phone.Controls.Maps; assembly=Microsoft.Phone.Controls.Maps” xmlsn:o=“clr-namespace:Microsoft.Phone.Controls.Maps.Overlays; assembly=Microsoft.Phone.Controls.Maps” ...

Get Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.