Last week, I pushed a change that will enable tomorrow’s trunk Firefox builds (Minefield) to access user-readable position information.
For example, instead only being able to work with:
37.3882005, -122.0834553
You can see the physical address as:
650 Castro St, Mountain View, California, 94041, US
This should help aide the many people that already know their physical address in familiar terms.
To access address elements, you simply do what you have been doing. The only modification is to test to see if there is an address associated with the position, and if so, access it:
navigator.geolocation.watchPosition(successCallback)
function successCallback(position)
{
if (position.address)
alert(position.address.postalCode);
}
Other fields on the address object are:
address.streetNumber address.street address.premises address.city address.region address.county address.countryCode address.postalCode
Please let me know what you think.
11 Comments
Good! A little strict. Most eastern counties have different address system. What’s its bugzilla number?
thanks. Right, there are dozen of ways to address places on the earth. The attributes listed are the most common we have found. We can add to this list as demand grows.
The bug number for this change is:
https://bugzilla.mozilla.org/show_bug.cgi?id=503942
For new issues, please file new bugs.
Does that also include geolocation switching so people can use things like geoclue?
hey chris,
this would allow geoclue to also uses these fields, yes! before this change, geoclue (or any other addon/provider) would have to do a bunch of extra work.
See bug 485472 for geoclue work.
Holly cow!!! Exactly what I needed _now_. Thanks Doug !
glad you like it, glaz. should be a bunch easier to use.
found a bug
https://bugzilla.mozilla.org/show_bug.cgi?id=505430
Thanks, posted a fix. give it a go, and if it works, we can push today.
“Premises” is a fairly “corporate” name for a building. How do I put in the address “Foobar House, VillageName, CityName, CountyName, Postcode” (which is my home address with placeholders)?
Gerv
Right, you could use the premise field:
address.premise = Foobar House – VillageName
address.city == CityName
address.county == CountyName
address.postalCode == Postcode
And how would it work for House, Road, Village, City, County, Postcode?