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

  • Jul. 30, 2014 at 23:05
    A devastating fire has torn through Eastbourne Pier, leaving the structure an "absolute red, molten, mess of flame and smoke".
    Read more»
  • Jul. 30, 2014 at 23:01
    The G7 group of economic powers warns President Putin of further sanctions after Russia called new US and EU penalties "destructive and shor...
    Read more»
  • Jul. 30, 2014 at 22:53
    A major span between New York City and New Jersey will be getting safety fence designed to prevent suicides, after an increase in deaths thi...
    Read more»
  • Jul. 30, 2014 at 22:39
    Ronny Deila suffers a nightmare first loss as Celtic boss with a 4-1 loss to Legia Warsaw in the Champions League qualifiers.
    Read more»
  • Jul. 30, 2014 at 22:33
    Liberia's government announced it is closing down all schools across the country and deploying troops to stop the spread of the deadly Ebola...
    Read more»
  • Jul. 30, 2014 at 22:16
    Users of the "dark net" service Tor who visited hidden websites may have had their identities revealed by a five-month long cyber-attack.
    Read more»
  • Jul. 30, 2014 at 21:52
    The US and UN condemn the shelling of a UN school housing civilians in Gaza, as Palestinians say Israeli attacks kill more than 100 in the d...
    Read more»
  • Jul. 30, 2014 at 21:51
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Jul. 30, 2014 at 21:42
    At least 20 people are killed after a landslide buries more than 40 houses and leaves up to 200 people trapped in a village in western India...
    Read more»
  • Jul. 30, 2014 at 20:44
    The Ebola virus poses a threat to the UK but health services here have the experience to deal with it, Foreign Secretary Philip Hammond says...
    Read more»
  • Jul. 30, 2014 at 20:37
    The US economy grew by 4% in the second quarter, according to a preliminary reading by the US Department of Commerce, beating expectations.
    Read more»
  • Jul. 30, 2014 at 20:15
    Bank of America's Countrywide unit must pay $1.3bn for selling defective home loans to US government mortgage lenders, a New York judge rule...
    Read more»
  • Jul. 30, 2014 at 20:08
    At least six people have been killed in a suicide bombing at a college in northern Nigeria's biggest city, Kano, witnesses say.
    Read more»
  • Jul. 30, 2014 at 20:01
    A deep-sea octopus has been observed nursing her eggs for more than four years - the longest brooding time seen in any animal.
    Read more»
  • Jul. 30, 2014 at 19:51
    England will be confident of beating India in the third Test to level the series, after setting them a target of 445.
    Read more»
  • Jul. 30, 2014 at 19:42
    At least 35 bodies are reportedly recovered from a military base that was overrun by Islamist-led militias in the Libyan city of Benghazi.
    Read more»
  • Jul. 30, 2014 at 19:14
    Tides and spin gave the Moon its strange lemon shape more than four billion years ago, research reveals.
    Read more»
  • Jul. 30, 2014 at 18:57
    Work on the eighth series of US sitcom The Big Bang Theory is delayed, as its cast members fight for higher salaries.
    Read more»
  • Jul. 30, 2014 at 18:13
    Security experts at HP raise concern about smart home devices after testing 10 app-controlled examples and discovering vulnerabilities.
    Read more»
  • Jul. 30, 2014 at 17:50
    No deal is in prospect in Argentina's debt talks in New York as Wednesday night's default deadline approaches.
    Read more»

Recent Comments:

Ehcjntublr

Jun. 11, 2014 at 06:06 PM

leebvfnnbovfmoebzjsbhjkf, http://www.pykbyrhrlo.com/ spdwthctlr

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.

Remedies for piles

May. 18, 2014 at 05:44 PM

Thanks for finally writing about > %blog_title% < Loved it!

Website

Mar. 25, 2014 at 08:19 PM

There are books, home study courses, workshops and other means of information, to gain the knowledge required to become the alpha leader. If you want ... Read more»

Titia

Feb. 15, 2014 at 01:48 AM

buy car insurance online prozac 40mg no rx best deals on vigra and cialis website auto insurance quoye www.evansvillecommunitytheatre.com ... Read more»

Archives:

Meet me on facebook: