HTML5 Browser Geolocating

by , Nov. 02, 2010 at 08:01 PM

Scripts: html5

 Who has ever thought it is posible to get geographic location data through the web browse? HML5 has made a break down with its new Geolocation API discribed in its specification.

Of not browser support this API like IE8, hopefully IE9 will support it. However, you can check this geolocation in others browsers as they are others advanced one: Firefox, Chrome Safari, ...

The Geolocation object is used by scripts to programmatically determine the location information associated with the hosting device. The location information is acquired by applying a user-agent specific algorithm, creating a Position object, and populating that object with appropriate data accordingly.

Objects implementing the Navigator interface (e.g. the window.navigator object) must also implement the NavigatorGeolocation interface [NAVIGATOR].
An instance of NavigatorGeolocation would be then obtained by using binding-specific casting methods on an instance of Navigator. This NavigatorGeolocation will provide a read-only object: Geolocation, it means you won't change its value. However it has three methods which are interessing for use to make the API work.

These are :

  1. getCurrentPosition: this method as it says, it is however a void method, it provide the postion's coordinates and so a callback function for this purpose
  2. watchPostion : this method returns a Id value for the started watch operation
  3. clearWatch: what does this method is clearing the watchPosition operation of the ID value the operation in execution

The best of the two last methods is you can build an itinerary navigator, itinerary parcours calculator, other apps. "wachPosition" returns periodically actual coords of the position of the navigator, in this case your phone, or other mobile devices connected to net.

Suppose you got your ephoney, or andoid phone, you may build an web application can that find shops, libraries, musea of the area where you are arriving.

Example javascript code:

  1. function init() {
  2. if (navigator.geolocation) {
  3. navigator.geolocation.getCurrentPosition(exportPosition, errorPosition);
  4. } else {
  5. getLocationYQL();
  6. document.getElementById('georesults').innerHTML = '<p>Your browser does not support HTML5 geolocation API.</p>';
  7. }
  8. }
  9. window.onload = init;

Note :

However the geoloaction API of HTML isn't yet enough accurate compared to the other GPS systems we know till now. But good people at W3C are working on it, i hope soon will be real to use this API.

Want to check this, visit this link : HTML5 geolocating you!

Available Comments :

Cr.frozen

Nov. 12, 2010 at 11:33 AM

Html5 geolocation is not accurate?
How come?

Administrator

Nov. 12, 2010 at 11:56 AM

The inaccuracy of the Geolocation Api of html5 may be it use the IP from your internet provider or ur pc has no GPS tools installed on it. Geolocation Api of html5 works fine with mobile internet, Android phones, iPhone and other Smart phones.
Howeever, i tested this api from my home, it gives an accuracy of 40 meters.
Html5 is still development.

Your Attention! Please do not post message with spam on this blog. We try to be cool to each other and post relevant comments and relating to the appropriated topic or entry. Let's try to get a nice conversation over here.

Leave a comment

Required!
Required!

Required!
Required!

Latest News

  • Apr. 19, 2014 at 08:23
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Apr. 19, 2014 at 08:01
    Police investigating how a seven-year-old boy received serious burn injuries in Aberdeen say there is "no evidence" so far of "any deliberat...
    Read more»
  • Apr. 19, 2014 at 06:04
    The fatal shooting of prominent dissident republican Tommy Crossan is condemned by Northern Ireland's first and deputy first ministers as de...
    Read more»
  • Apr. 19, 2014 at 05:25
    The captain of a South Korean ferry that capsized and sank this week explains after his arrest why he delayed giving evacuation orders.
    Read more»
  • Apr. 19, 2014 at 04:47
    A Brazilian second division football game is abandoned after 16 minutes, with one team saying they now have a court order to play in the top...
    Read more»
  • Apr. 19, 2014 at 03:44
    A 7.2-magnitude earthquake hits states in south and west Mexico, shaking buildings in the capital, but there are no reports of casualties or...
    Read more»
  • Apr. 19, 2014 at 03:43
    A powerful earthquake has struck Mexico City, shaking buildings and causing widespread panic.
    Read more»
  • Apr. 19, 2014 at 03:42
    At least 12 Sherpa guides have been killed after an avalanche on the slopes of Mount Everest, Nepali officials say.
    Read more»
  • Apr. 19, 2014 at 03:35
    The UN expresses outrage at a deadly attack on one of its bases in South Sudan, saying it could "constitute a war crime".
    Read more»
  • Apr. 19, 2014 at 03:34
    A lion on the loose in Llandrindod Wells
    Read more»
  • Apr. 19, 2014 at 03:29
    The 8 tribes of people who keep buying records
    Read more»
  • Apr. 19, 2014 at 03:26
    The airport that hosted a roll-call of presidents
    Read more»
  • Apr. 19, 2014 at 03:17
    Rhea birds can be extremely dangerous, plus other factlets
    Read more»
  • Apr. 19, 2014 at 03:00
    The Archbishop of Canterbury speaks of the Church of England's struggle to do "what is right" over the divisive issue of same-sex marriage.
    Read more»
  • Apr. 19, 2014 at 02:49
    The US threatens tougher economic sanctions if Russia fails to abide by a new international deal to help de-escalate the crisis in Ukraine.
    Read more»
  • Apr. 19, 2014 at 01:46
    Portrait painter Susanne du Toit on being an artist
    Read more»
  • Apr. 19, 2014 at 01:42
    Labour's Tristram Hunt is to issue a tough warning against religious extremism in schools.
    Read more»
  • Apr. 19, 2014 at 01:26
    The element that makes a familiar smell when mixed with urine
    Read more»
  • Apr. 19, 2014 at 01:02
    People convicted of commercial crimes overseas could be banned from running UK firms in an attempt to tackle "rogue directors", Business Sec...
    Read more»
  • Apr. 19, 2014 at 01:01
    The best news photographs from around the world
    Read more»

Recent Comments:

Website

Mar. 25, 2014 at 08:19 PM

There are books, home study courses, workshops and other means of information, to gain the knowledge required to become the alpha leader. If you want ... Read more»

Titia

Feb. 15, 2014 at 01:48 AM

buy car insurance online prozac 40mg no rx best deals on vigra and cialis website auto insurance quoye www.evansvillecommunitytheatre.com ... Read more»

Cheap online prescription glasses

Jun. 27, 2012 at 03:47 PM

I was suggested this blog by my cousin. I am not sure whether this post is
written by him as nobody else know such detailed about my difficulty.<... Read more»

Emmanuel

Jun. 23, 2012 at 04:02 PM

This article is about the awesome HTML 5 video feature which takes time for web developers to build up web video portals, gjust like does youtube. Wit... Read more»

Oil water separators

Jun. 21, 2012 at 12:37 PM

For the reason that the admin of this website is working,
no hesitation very rapidly it will be renowned, due
to its quality contents.

Archives:

Meet me on facebook: