

Geo.js, Building location-aware mobile websites with Javascript - akaalias
http://code.google.com/p/geo-location-javascript/

======
philfreo
For those of you interested in a similar wrapper for offline storage (via
Google Gears or HTML5 databases), here is the wrapper Google suggests you use:
<http://code.google.com/p/webstorageportabilitylayer/>

------
TweedHeads
This snippet uses the new navigator.geolocation.getCurrentPosition() feature
in Firefox 3.5

You will be redirected to Google Maps if you click the folowing link:

(You must click "share location" when prompted by the browser, you know,
privacy concerns)

    
    
      javascript:navigator.geolocation.getCurrentPosition(function(position){window.location.href="http://maps.google.com/?ll="+position.coords.latitude+","+position.coords.longitude;});
    

Drop it in your bookmarks toolbar and presto!

Or get it from here <http://mylittlehacks.appspot.com/geolocation>

~~~
karanbhangui
<http://pastie.org/541651> (added quotes, and doesn't get link cutoff)

edit: looks like you fixed it :D

------
eapen
Google Maps v3 (in beta) already utilizes the sensor variable - so I dont see
how this is advantageous for a mobile website. As for desktop apps - Google
also has an API function to determine your location based on your IP. But I
dont think it utilizes Firefox's geo-location ability.

<em>What is the benefit of this API compared to whats already available?</em>

~~~
akaalias
To me, in the context of mobile websites, it provides an answer/option to
providing localized content. Given you have/want localized content/filtering
of course.

Where up until now, the first answer to 'You want GPS location?' would have
been 'You'll need a native app.', it's now possible to just built a webapp
instead.

At least for requests that came our way for building native apps for the
iPhone, the most requested feature was 'ZOMG, make it localizable!', where the
rest would be just pulling data from a server.

Now, my option is to just built a mobile webapp that can use the lat/lng
without much fuss (still needs to degrade gracefully in case of older
phones/browsers of course).

~~~
karanbhangui
Out of curiosity, is there a reason why 'enableHighAccuracy' property isn't
set to true for android?

~~~
whoisstanimal
you can set them in your code pass them in as options, only that won't have
any effect yet on blackberry.

------
a2tech
Very cool-looks like this is the same code that is used in Google Maps for
location awareness in Firefox. It doesn't seem to like Opera (or it could be
my connection not being found) but it seems to be cross browser compatible.

~~~
jeresig
It looks like it's really only designed to work with devices that provide
Geolocation functionality. They have a list on their site:
[http://code.google.com/p/geo-location-
javascript/wiki/Suppor...](http://code.google.com/p/geo-location-
javascript/wiki/SupportedPlatforms)

I _think_ this also includes support for the Geolocation API found in Firefox
3.5, so they can probably add that to the list, as well.

~~~
timmaah
How does FF 3.5 get the location? The example asked me to share location, but
then showed me in the middle of New York City when in fact I am in Burlington
Vermont

~~~
whoisstanimal
FF 3.5 uses your IP address or wifi basestation id to retrieve the location
and there is no guarantee that is accurate. In order to be accurate you need
to use GPS or Cell Tower Locating from you cell phone.

~~~
timmaah
The service they use is particularly bad then. Most places I have tried get
within a few towns for my office. (Obviously none can get my home satellite
connection correct)

