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. 25, 2014 at 10:40
    The rest of Europe expects the UK to settle a £1.7bn EU budget demand "and that's that", a vice president of the European Parliament has sa...
    Read more»
  • Oct. 25, 2014 at 10:36
    England narrowly hold on for victory against Samoa in a pulsating Four Nations encounter in Brisbane.
    Read more»
  • Oct. 25, 2014 at 09:10
    Iran defies an international campaign and hangs a woman who killed a man she said was trying to sexually abuse her.
    Read more»
  • Oct. 25, 2014 at 09:04
    Who will prevail in Brazil's battleground state?
    Read more»
  • Oct. 25, 2014 at 08:54
    Johann Lamont stands down as leader of the Scottish Labour Party, accusing the party's UK leadership of treating Scotland as a "branch offic...
    Read more»
  • Oct. 25, 2014 at 07:40
    Police in New York say an axe attack on two officers was a terrorist act carried out by a radicalised Muslim convert.
    Read more»
  • Oct. 25, 2014 at 06:38
    A US judge has sentenced an ex-Colombian rebel to 27 years in prison for his role in the kidnapping of three American citizens in 2003.
    Read more»
  • Oct. 25, 2014 at 06:38
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Oct. 25, 2014 at 06:10
    Two nurses infected with Ebola while treating a patient in Dallas are declared free of the deadly virus, a day after the first infection in ...
    Read more»
  • Oct. 25, 2014 at 06:04
    The authorities in Mali confirm the death of the country's first Ebola patient, a two-year-old girl, and say many people were exposed to her...
    Read more»
  • Oct. 25, 2014 at 05:47
    A Malaysian diplomat appears briefly in court on charges of attempted rape in the New Zealand city of Wellington after being extradited.
    Read more»
  • Oct. 25, 2014 at 05:22
    A report into the route of the second phase of the controversial fast train project HS2 is expected to recommend a new station be built in C...
    Read more»
  • Oct. 25, 2014 at 03:56
    An Argentine ex-police chief and ex-interior minister are among 15 people given life sentences for involvement in a torture centre in the 19...
    Read more»
  • Oct. 25, 2014 at 03:13
    Pakistan's here today, gone tomorrow militant factions
    Read more»
  • Oct. 25, 2014 at 03:02
    Does a good cause justify little girls using bad language?
    Read more»
  • Oct. 25, 2014 at 02:58
    Egypt declares a three-month state of emergency in parts of the Sinai Peninsula after two attacks there killed at least 31 soldiers.
    Read more»
  • Oct. 25, 2014 at 02:27
    One person was shot dead and four students wounded in a school by a student who then took his own life, police in the US state of Washington...
    Read more»
  • Oct. 25, 2014 at 01:57
    Plans to turn an area of ancient Staffordshire woodland mentioned in the Domesday Book into a quarry anger conservationists.
    Read more»
  • Oct. 25, 2014 at 01:27
    Scientists from Harvard Medical School have discovered a way of turning stem cells into killing machines to fight brain cancer.
    Read more»
  • Oct. 25, 2014 at 01:21
    Picasso Museum in Paris reopens after a five-year renovation
    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: