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

  • Mar. 07, 2015 at 00:59
    A US woman who was abducted last month by masked gunmen in central Nigeria is now free, officials say.
    Read more»
  • Mar. 07, 2015 at 00:39
    Rory McIlroy launched his club into a lake during an erratic second round at the WGC-Cadillac Championship in Miami.
    Read more»
  • Mar. 07, 2015 at 00:38
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Mar. 06, 2015 at 23:56
    US authorities charge three men for their roles in what they claim is one of the biggest data breaches in American history.
    Read more»
  • Mar. 06, 2015 at 23:34
    Foreign ministers from the regional Unasur bloc promise to help Venezuela overcome a shortage of food, medicine and other products.
    Read more»
  • Mar. 06, 2015 at 23:21
    The US justice department is preparing to bring criminal corruption charges against Democratic Senator Robert Menendez, US media reports say...
    Read more»
  • Mar. 06, 2015 at 22:36
    A thrilling James Ward comeback gives Great Britain a 2-0 Davis Cup lead over the United States in a mammoth tie in Glasgow.
    Read more»
  • Mar. 06, 2015 at 22:01
    Russia and Germany call for the number of OSCE observers monitoring a truce in eastern Ukraine to rise from 500 to 1,000.
    Read more»
  • Mar. 06, 2015 at 21:56
    CIA director John Brennan says he has ordered one of the biggest structural reorganisations in the US spy agency's history.
    Read more»
  • Mar. 06, 2015 at 21:10
    The doctor who pulled US actor Harrison Ford from the wreck of a plane crash says he feared a fireball from the aircraft's leaking fuel.
    Read more»
  • Mar. 06, 2015 at 21:03
    Tanzanian police arrest 32 witchdoctors as part of the country's campaign to halt the murder of albinos for their body parts.
    Read more»
  • Mar. 06, 2015 at 20:29
    The US economy adds 295,000 jobs in February, while the unemployment rate fell to 5.5% from 5.7%, Labor Department figures show.
    Read more»
  • Mar. 06, 2015 at 20:14
    The fugitive US intelligence contractor Edward Snowden tells a Swiss audience he would love to get asylum in Switzerland.
    Read more»
  • Mar. 06, 2015 at 20:06
    Broadcasters say they will proceed with plans for three TV election debates, despite David Cameron saying he will only take part in one.
    Read more»
  • Mar. 06, 2015 at 19:41
    Mediators in peace talks between South Sudan's government and rebels have said the sides' failure to reach a deal is morally and politically...
    Read more»
  • Mar. 06, 2015 at 19:32
    In a newly-released video made by Michael Zehaf-Bibeau, the gunman who carried out attacks in Canada last year blames its foreign policy.
    Read more»
  • Mar. 06, 2015 at 18:38
    A middle-aged Dow Jones accountant who said he was forced to dress up as Father Christmas and branded an "old buffer" wins his unfair dismis...
    Read more»
  • Mar. 06, 2015 at 18:25
    The military commander of Syria's al-Nusra Front militant group, Abu Homam al-Shami, is reportedly killed in an air strike.
    Read more»
  • Mar. 06, 2015 at 17:42
    News photos from around the world
    Read more»
  • Mar. 06, 2015 at 17:42
    Apple, the biggest US company by market value, will be included in the Dow Jones Industrial Average from 19 March.
    Read more»

Recent Comments:

Emmanuel Ndayiragije

May. 05, 2011 at 04:30 PM

Salut Joannes,
Quand j'ai programmé ce système, je l'ai codé supportant l'englais seulement. Bientôt, je vais l'étendre pour pouvoir supporte... Read more»

Joannes

Apr. 27, 2011 at 02:16 PM

Why don't you write in french?

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... Read more»

Cr.frozen

Nov. 12, 2010 at 11:33 AM

Html5 geolocation is not accurate?
How come?

Amo

Oct. 20, 2010 at 11:36 PM

HTML5 is great stuff

Archives:

Meet me on facebook: