Hacker News new | past | comments | ask | show | jobs | submit login
Geo.js, Building location-aware mobile websites with Javascript (code.google.com)
29 points by akaalias on July 10, 2009 | hide | past | favorite | 13 comments



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>


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


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


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


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/


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.


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

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.


Yep, you are right, FF 3.5 is being provided with location by the Google Location Service (http://google-code-updates.blogspot.com/2009/04/google-locat...). Also, this service implements http://dev.w3.org/geo/api/spec-source.html, which should, once widely adopted, void the need of a wrapper library such as geo.js posted here.

Edit: Typo


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


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.


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)


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


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

edit: looks like you fixed it :D




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: