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 :


Nov. 12, 2010 at 11:33 AM

Html5 geolocation is not accurate?
How come?


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.

Natural hair care products

May. 27, 2014 at 09:05 AM

These are really great ideas in on the topic of blogging. You have touched some pleasant things here. Any way keep up wrinting.

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



Latest News

  • Nov. 27, 2014 at 19:53
    A judge says he is satisfied the MP called police officers "plebs" as he rules against Andrew Mitchell in a High Court libel action.
    Read more»
  • Nov. 27, 2014 at 19:06
    The cricketing world is rallying around bowler Sean Abbott amid fears he may never play again after Phillip Hughes's death.
    Read more»
  • Nov. 27, 2014 at 18:42
    A South African ventriloquist appears in court with his dummy to successfully challenge a gagging order.
    Read more»
  • Nov. 27, 2014 at 18:33
    Brazil legend Pele is transferred to a special care unit in Sao Paulo following treatment for a urinary infection.
    Read more»
  • Nov. 27, 2014 at 18:19
    Crude oil prices slump after the Opec oil producers' cartel decides not to cut output.
    Read more»
  • Nov. 27, 2014 at 18:16
    Australia cricketer Phillip Hughes dies in hospital, two days after being hit on the neck by a ball during a match in Sydney.
    Read more»
  • Nov. 27, 2014 at 18:15
    A powerful storm cut power to tens of thousands of homes and businesses in Brisbane, Australia, bringing "golf ball-sized" hailstones with i...
    Read more»
  • Nov. 27, 2014 at 18:11
    The American wife of London financier Sir Chris Hohn, Jamie Cooper-Hohn, is awarded £337m by a High Court judge in a divorce case.
    Read more»
  • Nov. 27, 2014 at 18:10
    The High Court bans a further 53 piracy sites, more than doubling the number that the UK's leading net providers must block.
    Read more»
  • Nov. 27, 2014 at 18:08
    A suicide bomber strikes a UK embassy vehicle in the Afghan capital Kabul, with a British worker and an Afghan staff member among those kill...
    Read more»
  • Nov. 27, 2014 at 18:07
    The challenges facing oil exporters as prices slump - in 60 seconds
    Read more»
  • Nov. 27, 2014 at 18:02
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Nov. 27, 2014 at 18:00
    The Scottish Parliament should have the power to set income tax rates and bands, the body on strengthening devolution recommends.
    Read more»
  • Nov. 27, 2014 at 17:59
    A level of calm returns to the streets of Ferguson after two nights of unrest, although dozens of protesters have been arrested in Californi...
    Read more»
  • Nov. 27, 2014 at 17:36
    Best-selling novelist PD James, who created crime-fighting sleuth Adam Dalgliesh, dies at the age of 94.
    Read more»
  • Nov. 27, 2014 at 17:29
    Peter Kay is bringing back his hit TV show Phoenix Nights for two live shows in aid of Comic Relief.
    Read more»
  • Nov. 27, 2014 at 17:23
    Germany's unemployment rate has hit a record low of 6.6%, but falling inflation has raised eurozone deflation fears.
    Read more»
  • Nov. 27, 2014 at 17:22
    At least 10 people are killed in a gun battle between Indian troops and suspected Pakistani militants in the disputed territory of Kashmir.
    Read more»
  • Nov. 27, 2014 at 17:21
    Why some Africans criticise Geldof over Band Aid 30
    Read more»
  • Nov. 27, 2014 at 17:06
    Shock Treatment, the sequel to cult hit Rocky Horror Picture Show, is to be adapted for the stage in London.
    Read more»

Recent Comments:


Sep. 25, 2014 at 11:59 AM

Very nice site!


Sep. 25, 2014 at 06:32 AM

Very nice site! cheap goods


Sep. 23, 2014 at 06:22 PM

Very nice site!


Sep. 23, 2014 at 06:22 PM

Very nice site! cheap goods


Sep. 23, 2014 at 06:21 PM

Very nice site! cheap goods


Meet me on facebook: