⬆️ ⬇️

Geolocation in Windows 7 without GPS

Have you seen a lot of laptops that are equipped with a GPS sensor? Approximate estimates can be found here , 58 pieces out of 4380, that is 1.3%. Frankly speaking - not much. It’s hard to name all the reasons why manufacturers do not equip laptops with an inexpensive chip, but our note is about how to equip your laptop with geolocation functionality, even if you don’t have a GPS sensor. And at the same time you will learn how very simple it is to get your coordinates programmatically.



Talk about the weather?



Do you use a weather gadget in Windows 7? Until recently, I did not use it, because it was too lazy to drive another city into my hand (and I travel a lot). The option to automatically determine my coordinates did not work.

Windows 7 Weather Gadget Settings

The thing is that this gadget is trying to determine your coordinates through the Windows7 Sensor API . And requires a sensor driver. Recently, preparing a presentation for the Platform 2011, I came across the Geosense sensor, which very well determines the coordinates. For weather service, they are 100% suitable.

Windows 7 Weather Gadget

In fact, the accuracy is high, it works on the basis of the Google Location Service (WiFi and IP base) and I managed to test it in at least three places:



Do not forget to only configure this sensor as the default one, since the Orion sensor in Russia, unfortunately, does not work accurately enough. Geolocation Sensor Settings



We determine the coordinates programmatically.



Excuse me, sir, where are we?

-You are in the balloon basket, gentlemen.

Holmes, in a whisper: -Watson, I bet that this person is a programmer.







The Windows 7 Sensor API is also implemented in the .NET Framework 4.0. You just need to write literally 3 lines of code to understand where you are:

')

Location Program Code

I am now in Sheremetyevo D, connected to the Terminal-D WiFi-Free hotspot and this is what this program returns to me:

Geolocation results in BingMaps



Little about security



Of course, in Windows 7 it is possible to set permissions to use this API. If your application is trying to determine the coordinates, a warning will appear:

Enable sensor

You can also configure user access:

Configuration of sensors for users

All calls to the geolocation API are recorded in the log:

image



Summary



Of course, such geolocation does not replace GPS at all. First of all, because of the accuracy, and sometimes there are mistakes. But it can help out when GPS is not working (in buildings, in conditions of poor signal) and if you have an Internet connection. And as for determining the weather or other contextual services (for example, in social applications) is suitable for sure.



You can download the source code for a simple console application using the Geolocation API from the MSDN Code Gallery at code.msdn.microsoft.com/Windows-7-Geolocation-API-25585fac

Source: https://habr.com/ru/post/108548/



All Articles