No Device? No GPS? No Matter! – (With Code!)
August 2, 2010 44 Comments
Necessity is the mother of all invention and so I went about creating a quick application to better help simulate GPS coordinates when developing for WP7. Most developers don’t have a test device and two common reasons for asking for one is for the GPS and for the accelerometer. The latter has been simulated quite well (via the HTC HD2 or the Wiimote), but the former is usually simulated by manually typing in (or downloading a set of) coordinates. I’m currently reading up on WCF and decided to kill two birds with one stone – learn WCF and help other developers.
So, what is it? Simple – A locally hosted server displaying Bing maps and a client (e.g. your WP7 app) consuming those coordinates. As you move your mouse along the map, the GPS coordinates are retrieved and sent to the phone. This opens up quite a few possibilities. For example, you could store the coordinates every X seconds in a list to generate a ‘path’ that simulates someone driving from one point to another. If you need to know exact coordinates for your application, you can also extend the app so that you can press a key whenever you want to store a particular coordinate. Whatever you use it for, hopefully it saves you time and makes it easier to develop the GPS aspects of your application. Check out the video and source code below.
The source code is not designed to be used in production and was created to easily simulate GPS location. Functionality over form in this case, so don’t take it as a best-practise guide😉.
Hope you find it useful! Any problems understanding the code, or if it’s not working for you, feel free to comment and I’ll try and help.
Tom Verhoeff has pointed out that you may need to add Replace(‘.’,’,’) to the values for it to parse. This is down to your locale, so changing locale settings would also work.