Getting the position information of the site visitor using the HTML5 geolocation API is fairly simple. It utilizes the three methods that are packed into the navigator.geolocation object — getCurrentPosition(), watchPosition() and clearWatch(). The following is a simple example of geolocation that displays your current position.
The Geolocation API gives programs access to the web browser’s geolocation functionality, which can tell the program the device’s location on Earth. The Geolocation API is among the most well-supported HTML5 APIs and is implemented in about 90 percent of desktop and mobile browsers, including all of the big ones, except for Opera Mini.
IP based geolocation services can only provide an approximate measure of geolocation accuracy. With these services, you can obtain 95 percent to 99 percent accuracy of a user’s country. IP based geolocation services provide 55 percent to 80 percent accuracy for a user’s region or state. IP Geolocation, ISP, country, city, latitude, longitude and other information of IP address 188.8.131.52
Since Geolocation API is an HTML5 feature, make sure your doctype is HTML5 (e.g. ). Make sure you're calling Geolocation APIs (such as geolocator.locate() and geolocator.watch()) from a secure origin (i.e. an HTTPS page). In Chrome 50+, Geolocation API is removed from unsecured origins. Other browsers are expected to follow. Geolocation results for 184.108.40.206: City: Region: Washington Region Code: WA Region Name: Washington DMA Code: Country Name: United States Country Code: US In the EU?: 0 EU VAT Rate: Latitude: 47.6092 Longitude: -122.3314 Radius of Accuracy (Miles): 1000 Timezone: America/Los_Angeles Currency Code: USD Currency Symbol: $ Exchange Rate: 1