October 31st, 2022

How can I test my geolocation code on a system without a GPS?

After you put your Windows system into Developer Mode, you have the opportunity to turn on the Windows Device Portal Web server.

The Windows Device Portal REST API gives you a way to control various parts of the system remotely. And the one that’s interesting for today’s topic is the REST API for injecting artificial GPS data. After sending the REST command to enable GPS overrides, you can use subsequent REST commands to inject a specific latitude and longitude into the system’s geolocator.

Now you can test geolocation on your development machine without having to drag it on a cart around the building. On the other hand, it also means you lost one justification for needing to take a trip to a tropical island “to test that the program correctly detects a change in location to a tropical island.”

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.