Geolocation Address

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.

This entry was posted in mozilla and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

11 Comments

  1. Posted July 20, 2009 at 11:04 am | Permalink

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

  2. Posted July 20, 2009 at 11:11 am | Permalink

    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. Posted July 20, 2009 at 11:27 am | Permalink

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

  4. Posted July 20, 2009 at 11:32 am | Permalink

    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
    Posted July 21, 2009 at 4:13 am | Permalink

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

    • Posted July 21, 2009 at 9:32 am | Permalink

      glad you like it, glaz. should be a bunch easier to use.

  6. Daniel Glazman
    Posted July 21, 2009 at 4:59 am | Permalink
    • Posted July 21, 2009 at 9:31 am | Permalink

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

  7. Posted July 21, 2009 at 11:45 am | Permalink

    “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

    • Posted July 21, 2009 at 11:49 am | Permalink

      Right, you could use the premise field:

      address.premise = Foobar House – VillageName
      address.city == CityName
      address.county == CountyName
      address.postalCode == Postcode

  8. Posted July 22, 2009 at 5:01 am | Permalink

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

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>