I'm developing an anti-theft software to get computers exact location. Notebooks with built-in gps are very rare in my country so I have to use HTML5 Geolocation in my application.
For Internet Explorer 9+, there is a registry key that you can add urls to allow a url without needing user verification. If you add an REG_DWORD
value named domain.com under HKCU\Software\Microsoft\Internet Explorer\Geolocation\HostConsent
path browser will allow geolocation request automatically. However I can't run Internet Explorer hidden so thats not working for me since thief shouldn't realize and see what's going on.
I prefer second way because Internet Explorer is now terminated by Microsoft and I think next version will have different structure.
How can I embed and use Webkit or GeckoFX to my application? How can I allow a geolocation request programmatically in this application?
HTML5 Geolocation API lets you share your location with your favorite web sites. A JavaScript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map.
HTML5 geolocation lets you find the geographic coordinates of a website visitor's current location like the longitude and the latitude. The information provided by HTML 5 geolocation can be used to optimise the browsing experience.
So yes, getting a user's lat/lon is 'free'--no need to pay for that feature by itself.
Open the Google Chrome app. Touch the Chrome menu . Touch Settings > Site settings > Location. Use the switch to either have Chrome ask before accessing your location, or to block all sites from accessing your location.
Relying on a hidden browser is a risky solution, and it will inevitably break at some point in the future.
Instead you want to build geolocation functionality into your own application. The two major sources of location info are your IP address (which you then feed into any of the GeoIP providers) and cellular/Wi-Fi stations visible (which you feed into Google geolocation API).
Have a look at the GeoCoordinateWatcher
class which is defined in the System.Device
assembly
The GeoCoordinateWatcher class supplies coordinate-based location data from the current location provider. The current location provider is prioritized as the highest on the computer, based on a number of factors, such as the age and accuracy of the data from all providers, the accuracy requested by location applications, and the power consumption and performance impact associated with the location provider. The current location provider might change over time, for instance, when a GPS device loses its satellite signal indoors and a Wi-Fi triangulation provider becomes the most accurate provider on the computer.
Usage example :
static void Main(string[] args)
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
watcher.StatusChanged += (sender, e) =>
{
Console.WriteLine("new Status : {0}", e.Status);
};
watcher.PositionChanged += (sender, e) =>
{
Console.WriteLine("position changed. Location : {0}, Timestamp : {1}",
e.Position.Location, e.Position.Timestamp);
};
if(!watcher.TryStart(false, TimeSpan.FromMilliseconds(5000)))
{
throw new Exception("Can't access location");
}
Console.ReadLine();
}
I think this class relies on the same mechanism than the one use by Internet Explorer.
When you will use it, you will have an icon in your system notification tray telling that location has recently been accessed.
You will also have an entry added on windows logs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With