Reputation: 91
I have a snippet
navigator.geolocation.getCurrentPosition(function(position) {
// do somehthing
});
but the result returned is different between chrome and firefox. the position in chrome have no adress property.
anyone can help?
Thanks
Upvotes: 2
Views: 1913
Reputation: 4473
It looks like Firefox is a bit ahead of the curve with the position interface. The standard does not currently support an address property.
Geolocation API specifications:
The Position interface is the container for the geolocation information returned by this API. This version of the specification allows one attribute of type Coordinates and a timestamp. Future versions of the API may allow additional attributes that provide other information about this position (e.g. street addresses).
The position object that is returned by the getCurrentPosition()
Method contains a coordinate property with the latitude and longitude.
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
// do something with lat and lng
});
If you need the street address you are going to have to use a geocoding service (like Google Maps Geocoder, which is what Firefox is using to find the address) to look up the address.
Upvotes: 3