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

  • Oct. 23, 2014 at 01:42
    A baby girl is killed and eight others injured after a car hits pedestrians in Jerusalem, in what Israeli police describe as a "terrorist at...
    Read more»
  • Oct. 23, 2014 at 01:40
    Military leaders failed to calculate the magnitude of the conflict in Afghanistan, the former head of the British army, Gen Sir Peter Wall, ...
    Read more»
  • Oct. 23, 2014 at 01:32
    Police killer Harry Roberts is to be released from prison after more than 45 years, after a decision by the Parole Board.
    Read more»
  • Oct. 23, 2014 at 01:00
    The NHS in England needs extra money and drastic changes to the way services are organised if patient care is not to suffer, health bosses s...
    Read more»
  • Oct. 23, 2014 at 00:59
    Lloyds Banking Group is planning to cut around 9,000 jobs - around a tenth of its entire workforce - over the next three years, the BBC unde...
    Read more»
  • Oct. 23, 2014 at 00:59
    President Barack Obama expresses cautious optimism about the Ebola situation in the US, as new screening rules are introduced in the country...
    Read more»
  • Oct. 23, 2014 at 00:56
    A huge security operation is under way in Canada's capital Ottawa after a gunman killed a soldier at a war memorial and shots were fired in ...
    Read more»
  • Oct. 23, 2014 at 00:19
    A nine-year-old boy and a 44-year-old man die after a house fire in Penistone, near Barnsley, South Yorkshire Police said.
    Read more»
  • Oct. 23, 2014 at 00:18
    Will coal exports kill the Great Barrier Reef?
    Read more»
  • Oct. 22, 2014 at 23:58
    Mexico orders the arrest of the mayor of the southern town of Iguala, where 43 students disappeared after clashing with police last month.
    Read more»
  • Oct. 22, 2014 at 23:18
    Real Madrid score three goals in the first half to secure a comfortable 3-0 win at Liverpool in the Champions League.
    Read more»
  • Oct. 22, 2014 at 23:03
    Arsenal score twice in the final two minutes to earn a dramatic comeback win at Champions League opponents Anderlecht.
    Read more»
  • Oct. 22, 2014 at 22:37
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Oct. 22, 2014 at 20:36
    The World Health Organization's emergency committee holds talks on travel restrictions and screening measures on the Ebola outbreak.
    Read more»
  • Oct. 22, 2014 at 20:16
    A US federal jury finds four Blackwater security guards guilty of killing 14 Iraqis in a square in Baghdad in 2007.
    Read more»
  • Oct. 22, 2014 at 20:01
    Cuba sends a second group of medical staff to West Africa to help fight the Ebola outbreak, becoming the biggest single provider of healthca...
    Read more»
  • Oct. 22, 2014 at 19:53
    A US citizen freed from detention in North Korea receives an emotional homecoming in Ohio as Washington works to release two other Americans...
    Read more»
  • Oct. 22, 2014 at 19:44
    US car safety regulators expand a recall of vehicles with potentially dangerous Takata airbags to 7.8 million, warning that owners should ta...
    Read more»
  • Oct. 22, 2014 at 19:06
    DNA analysis of a 45,000-year-old human has helped scientists pinpoint when our ancestors interbred with Neanderthals.
    Read more»
  • Oct. 22, 2014 at 18:45
    Former Dr Feelgood guitarist Wilko Johnson says he has been "cured" of the terminal pancreatic cancer with which he was diagnosed in 2012.
    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: