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

  • Sep. 02, 2014 at 06:01
    The US military says it carried out a military operation against al-Qaeda-linked al-Shabab militants in Somalia.
    Read more»
  • Sep. 02, 2014 at 05:14
    Japanese wages unexpectedly log their strongest increase since 1997, which may provide a boost to consumer confidence and spending.
    Read more»
  • Sep. 02, 2014 at 04:50
    The White House says securing the release of three American citizens detained in North Korea is a "top priority", after they appealed for he...
    Read more»
  • Sep. 02, 2014 at 04:24
    China's museum boom hatches roast duck tribute
    Read more»
  • Sep. 02, 2014 at 04:22
    Radamel Falcao's loan move to Manchester United was the major deadline day signing as summer spending hits a record £835m.
    Read more»
  • Sep. 02, 2014 at 04:10
    A British activist who campaigns for better labour conditions is set to go on trial in Thailand charged with criminal defamation.
    Read more»
  • Sep. 02, 2014 at 03:54
    How Americans join the fight in Syria
    Read more»
  • Sep. 02, 2014 at 03:43
    Does the rest of the UK care if the Scots become independent?
    Read more»
  • Sep. 02, 2014 at 03:38
    The FBI looks into allegations that the online accounts of celebrities have been hacked, leading to intimate pictures being posted online.
    Read more»
  • Sep. 02, 2014 at 03:31
    How much has the Ice Bucket Challenge achieved?
    Read more»
  • Sep. 02, 2014 at 03:07
    Anti-euro but pro-EU party shakes up German politics
    Read more»
  • Sep. 02, 2014 at 02:57
    Corals stir up the water, creating vortices that draw in nutrients and drive away waste, research reveals.
    Read more»
  • Sep. 02, 2014 at 02:31
    Iraqi Shia and Kurdish forces capture an Islamic State stronghold, as a BBC team enters Amerli the day after a two-month siege ends.
    Read more»
  • Sep. 02, 2014 at 02:31
    Manchester United sign Colombia international striker Radamel Falcao on loan from Ligue 1 side Monaco.
    Read more»
  • Sep. 02, 2014 at 02:13
    Arsenal sign Manchester United and England forward Danny Welbeck on a "long-term" deal for £16m.
    Read more»
  • Sep. 02, 2014 at 02:04
    Why Paris is forgetting Ernest Hemingway
    Read more»
  • Sep. 02, 2014 at 01:58
    In 2013 China had a new museum open almost every day of the year on average, resulting in some slightly bizarre attractions
    Read more»
  • Sep. 02, 2014 at 01:52
    A joint session of parliament is to be held in Pakistan as PM Nawaz Sharif seeks to gain support against protesters calling for his resignat...
    Read more»
  • Sep. 02, 2014 at 01:31
    Russia has launched a 'great war' that could claim tens of thousands of lives, Ukraine's defence ministry warns amid rebel offensive.
    Read more»
  • Sep. 02, 2014 at 01:30
    The number of people struggling with payday loans has risen by 42% in the past year, according to the debt charity StepChange.
    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: