In my twitter stream I caught someone once commenting about how hard it was to test a GPS enabled Windows Phone 7 app while in a building and how he was getting wet hanging out the window... (Yes, Clint, talk'n about you... )
That's a good point. How DO you develop or test your GPS consuming Windows Phone 7 app in the building or worse yet, in the emulator? How can you test it to see if it works in other locations besides the one you're at right now? Say in another country, state, area, etc?
I've tried to tell my DFO (Domestic Financial Officer... aka my wife) that I need to get on a plane to test my GPS WP7 app but she just gave me "the look".
"All Windows Phone devices have built-in Assisted GPS (aGPS), which is used by various phone applications including maps, camera, and search (to provide location-based search results).
Developers can access location information on Windows Phone by using the System.Device.Location namespace, which is supported in .NET 4 and later. The GeoCoordinateWatcher class supplies location data based on latitude and longitude coordinates. The Windows Phone GPS Emulator (a small WPF application) and one WP7 DLL enable you to create complex paths that you can play back just as if you were driving or walking, then debug your application on the emulator or a real device without leaving the comfort of your home or office.
Once you’ve completed your testing and debugging, you only need to change a single line of code to switch the device back to real GPS.
The Recipe includes:
- The Windows GPS Emulator application
- The Windows Phone GPS Emulator Client DLL
- A simple Windows Phone Test client
- An end-to-end Windows Phone App using Bings maps (a more complex sample)
Using the GPS Emulator lets you create complex path that you can playback just as if you were driving or walking. Then, you can choose your Windows Phone application and receive the location information form the GPS Emulator just as if you got it via the real GPS.
Using GPS Emulator with your Windows Phone Application
But first thing first, let’s figure out how does the GPS Emulator helps you debug your Windows Phone client application?
Here's a snip from the included docx
Working with the GeoCoordinateWatcher is relatively simple. Later in this piece, we’ll explain in more detail how to work with that class and how to test your application on a Windows Phone 7. However, sometimes your application requires more than just a single location to track movement, and you may need to test how your application behaves in different locations.
At these times, it may look odd to be driving around the block with your Windows Phone attached to a laptop while you try to debug your application.
Don’t worry—you’re in good hands. The Windows Phone GPS Emulator (a small WPF application) and one WP7 DLL enable you to debug your application on the Windows Phone emulator or a real device without leaving the comfort of your home or office. Once you’ve completed your testing and debugging, you only need to change a single line of code to switch to the device back to real GPS.
With the GPS Emulator, you can set a location anywhere on the globe by using the map display. Furthermore, you can plan routes with multiple intermediate waypoints, or use Bing services to calculate driving directions between locations. Once you’ve planned a route, you can simulate driving through the pre-defined waypoints along the path.
As you can see in Image 1, most of the window area of the GPS Emulator is dedicated to the Map control. You can fully interact with it by panning, zooming, and setting locations. A single left mouse click is used to set the current location (shown in a purple circle); double clicking sets a waypoint on a route.
1. Waypoint editor enables you to add a new point by setting the latitude (Lat) and longitude (Long). You can also search for well-known locations (such as Pike Place Market in Seattle) or for a street address. Each point you find can be added to a route. You can also edit existing points on the route.
2. The Route displays the list of waypoints on a given route. You can edit each point, change its location, or change the time it takes to simulate a drive from the current point to another point.
3. Simulation enables you to control the speed at which you play back the route. You can start and stop the route simulation if you want to simulate a traffic light.
4. The Connection indicator turns green when your Windows Phone application is connected to the GPS Emulator. The connection is made over HTTP by using WCF.
5. Map Type enables you to choose a Road, Aerial, or Hybrid view of the main map control.
What's best IMHO is that you get the code to the emulator too...
- Here’s a few more links you might find interesting:
Adventures with the GPS Emulator Recipe by Mike Ormond'
- GPS Emulator for Windows Phone 7 from Global Nerdy
- App Hub (Windows Phone 7 & XBox 360 development hub)
- Windows Phone 7 Development Tools and Resources, from MSDN Magazine
- Windows Phone 7 Developer Tools, from MSDev
- What's better than 20 "Silverlight for Windows Phone 7 toolkit" In Depth articles? 21!
- Coding4Fun Windows Phone Toolkit
- Some Useful WP7 Content for your Toolbag
- Master List of Windows Phone Developer Tips
- Must Have Windows Phone 7 Toolkits