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

  • Jan. 26, 2015 at 21:15
    The German government warns Greece that it must meet its commitments to lenders, after the election win of the Greek anti-austerity Syriza p...
    Read more»
  • Jan. 26, 2015 at 21:01
    MPs overwhelmingly reject a bid to suspend fracking for shale gas - but agree to Labour proposals to impose new conditions.
    Read more»
  • Jan. 26, 2015 at 20:54
    Holders Arsenal are drawn against Championship side Middlesbrough in the fifth round of the FA Cup.
    Read more»
  • Jan. 26, 2015 at 20:51
    Ten people have died after an F-16 fighter jet crashed at a military base in Spain, the country's Defence Ministry says.
    Read more»
  • Jan. 26, 2015 at 20:38
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Jan. 26, 2015 at 20:35
    Iowa gathering sinks 2016 return hopes
    Read more»
  • Jan. 26, 2015 at 19:51
    Kurdish forces have driven Islamic State (IS) militants from of Kobane, officials say, ending a four-month battle for the northern Syrian to...
    Read more»
  • Jan. 26, 2015 at 19:50
    A car ban has been announced in New York City as a blizzard that could dump up to 90cm (3ft) of snow heads towards the US north-east.
    Read more»
  • Jan. 26, 2015 at 19:49
    A man is charged with the murder of a 19-year-old man, who died in a machete attack outside a pub.
    Read more»
  • Jan. 26, 2015 at 19:42
    A flying device known as a "quad copter" triggered a security alert when it landed in the grounds of the White House, a US official says.
    Read more»
  • Jan. 26, 2015 at 19:08
    Sudan's Chinese-built palace shows new balance of power
    Read more»
  • Jan. 26, 2015 at 18:42
    Facebook has blocked a page which a Turkish court claimed was offensive to the Prophet Muhammad.
    Read more»
  • Jan. 26, 2015 at 18:41
    A study links commonly used medicines, including over-the-counter treatments for conditions such as insomnia and hay-fever, to dementia.
    Read more»
  • Jan. 26, 2015 at 18:33
    Irish airline Aer Lingus says it is considering a revised offer of €2.55 a share from British Airways owner IAG.
    Read more»
  • Jan. 26, 2015 at 18:22
    The Church of England has consecrated its first female bishop, the Reverend Libby Lane, in a ceremony at York Minster.
    Read more»
  • Jan. 26, 2015 at 18:11
    Extreme weather arising from a climate phenomenon in the Pacific Ocean will get much worse as the world warms, according to climate modellin...
    Read more»
  • Jan. 26, 2015 at 18:11
    New high-speed video footage suggests that the classic chemistry explosion of an alkali metal in water is driven by positive charges repelli...
    Read more»
  • Jan. 26, 2015 at 18:10
    A trial involving France's richest woman has begun in Bordeaux with a revelation that one of the key defendants tried to commit suicide
    Read more»
  • Jan. 26, 2015 at 17:58
    In his first TV interview for two years, Lance Armstrong discusses forgiveness, the future and for what he is and is not sorry.
    Read more»
  • Jan. 26, 2015 at 17:58
    Lance Armstrong says the time is coming when he should be forgiven, and tells the BBC he would do it again under the same circumstances.
    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: