Domanda

I've been asked to create a JavaScript solution to get a User's address (mainly postcode). We require a high level of accuracy for this.

I have decided on the following solution that uses Google Maps API for Business. I have mocked up a working example and it works well. Do you think this will be reliable and accurate in the wild.

Solution:

If (Mobile/ Tablet) use Browsers W3C Geolocation API (returns) Latitude/Longitude + Accuracy. W3C Geolocation API: http://dev.opera.com/articles/view/how-to-use-the-w3c-geolocation-api/

If (Desktop Machine/ IE8/ IE7) use Google Geolocation API (returns) Latitude/Longitude + Accuracy. https://developers.google.com/maps/documentation/business/geolocation/

Take the result with the Highest Accuracy.

if (Accuracy is poor) Ask User for postcode.

(else) Use the result with the Highest Accuracy and run it through the Google Reverse Geocoding API (Returns) Users Address with Postcode. https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding

È stato utile?

Soluzione 2

We have run a few prototypes and have found that this approach is good. Apart from horrible accuracy from the Google Geolocation API. It seems solid. There is one issue with Usability of the W3C Geolocation popup. Some users on desktop miss this.

Altri suggerimenti

Judging accuracy is a bit difficult without some understanding of your use case,as especially for desktop devices there are plenty of cases (eg. VPNs, corporate networks etc) where the geolocated address will be quite different from the user's actual address. Good enough for the default view of a store locator, probably not good enough for many other things.

If you do decide to proceed with this, the main catch is that the free version of the Google Geolocation API is restricted to 100 queries per day:

https://developers.google.com/maps/documentation/business/geolocation/#usage_limits

You will need to purchase a Maps for Business license to get more quota, or if you were planning on using the results outside a Google map.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top