HTML5 Geolocation with IpForensics fallback
An example of how you would use the ipdata API as a fallback for when HTML5 Geolocation fails or if the user blocks geolocation requests from your website
This example is adapted from the Wikipedia article on W3C Geolocation. Note that it handles every error by making a call to the IpForensics API to get the lat/long.
Also note that instead of getting the lat/long
(that is when you fall back to our service) and then using another service to geocode the lat/long
to a place i.e. city or country. You could simply get the country, city, region, postal code and numerous other attributes from the this.responseText
response object in the example below.
Always reference the API endpoint for complete response result
Last updated