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.

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

Required!
Required!

Required!
Required!

Latest News

  • Nov. 22, 2014 at 00:47
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Nov. 22, 2014 at 00:22
    US President Barack Obama vows to press for further immigration reform, as Republicans condemn his use of executive powers on the issue.
    Read more»
  • Nov. 21, 2014 at 23:38
    An outbreak of plague in Madagascar has killed 40 people and infected dozens of others, the World Health Organization says.
    Read more»
  • Nov. 21, 2014 at 23:32
    US stocks close at yet another record high after China announced a surprise rate cut and the head of the European Central Bank hinted at fur...
    Read more»
  • Nov. 21, 2014 at 23:25
    The UK criticises an Argentine law requiring public transport vehicles to carry signs declaring the nation's sovereignty claim over the Falk...
    Read more»
  • Nov. 21, 2014 at 22:25
    Iran's foreign minister says he has heard "no new ideas" as talks with world powers on Tehran's nuclear programme stretch into the evening.
    Read more»
  • Nov. 21, 2014 at 22:11
    US Vice-President Joe Biden, on a visit to Kiev, warns Russia of "greater isolation" as Ukraine marks a year since the start of its revoluti...
    Read more»
  • Nov. 21, 2014 at 21:49
    Ed Miliband says a Labour MP who quit her role after tweeting a picture of a house with three England flags and a white van parked outside "...
    Read more»
  • Nov. 21, 2014 at 21:45
    At least 50 people have been massacred by machete and axe-wielding attackers in eastern DR Congo, according to activists.
    Read more»
  • Nov. 21, 2014 at 21:04
    Two men die and at least six other people are injured as part of a balcony collapses in west London.
    Read more»
  • Nov. 21, 2014 at 20:57
    Lewis Hamilton says his "spectacular" Mercedes is the best F1 car he has driven as he builds up to the title-deciding Abu Dhabi GP.
    Read more»
  • Nov. 21, 2014 at 20:27
    Zambia's governing Patriotic Front suspends President Guy Scott as party leader amid a power struggle ahead of elections in January.
    Read more»
  • Nov. 21, 2014 at 20:11
    Nigel Farage says UKIP can become a major force at next year's general election after its victory in the Rochester and Strood by-election.
    Read more»
  • Nov. 21, 2014 at 20:10
    Premier League referee Michael Oliver quits his role at Northumberland FA over a decision not to punish an official for sexist language.
    Read more»
  • Nov. 21, 2014 at 20:02
    Two retired Chilean colonels - Ramon Caceres and Edgar Cevallos - are jailed for torturing the father of President Michelle Bachelet in 1973...
    Read more»
  • Nov. 21, 2014 at 19:54
    June Steenkamp reflects on her daughter's killing by Pistorius
    Read more»
  • Nov. 21, 2014 at 19:33
    Aviva and Friends Life are in talks about a possible £5.6bn merger deal, the two insurance companies have said.
    Read more»
  • Nov. 21, 2014 at 19:18
    The chairman and co-founder of Twitter is in London for the global launch of his new company 'Square'.
    Read more»
  • Nov. 21, 2014 at 19:04
    Eleven people have been killed in a stampede after a religious service in a stadium in Zimbabwe, police say.
    Read more»
  • Nov. 21, 2014 at 18:55
    Republicans agree that President Obama's executive action is a gross abuse of power. What to do about it, however, has them heading in diffe...
    Read more»

Recent Comments:

Pharmb740

Sep. 25, 2014 at 11:59 AM

Very nice site!

Pharmf503

Sep. 25, 2014 at 06:32 AM

Very nice site! cheap goods http://apeyixo2.com/ysyaqqs/4.html

Pharmf80

Sep. 23, 2014 at 06:22 PM

Very nice site!

Pharmf581

Sep. 23, 2014 at 06:22 PM

Very nice site! cheap goods http://aieopxy2.com/osovrrv/4.html

Pharmg443

Sep. 23, 2014 at 06:21 PM

Very nice site! cheap goods

Archives:

Meet me on facebook: