Skip to content

Geolocation Address

July 20, 2009

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.

From → Uncategorized

11 Comments
  1. Good! A little strict. Most eastern counties have different address system. What’s its bugzilla number?

  2. 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. :-)

  3. Does that also include geolocation switching so people can use things like geoclue?

  4. 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.

  5. Daniel Glazman permalink

    Holly cow!!! Exactly what I needed _now_. Thanks Doug !

    • Thanks, posted a fix. give it a go, and if it works, we can push today.

  6. “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

  7. And how would it work for House, Road, Village, City, County, Postcode?

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.