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

  • Dec. 20, 2014 at 03:05
    A 28-year-old man is detained on suspicion of the murder of an off-duty PC who died after being attacked in Liverpool city centre.
    Read more»
  • Dec. 20, 2014 at 02:59
    Sony Pictures says it is looking at alternative ways to release film satire The Interview, cancelled in the wake of a cyber-attack.
    Read more»
  • Dec. 20, 2014 at 02:42
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Dec. 20, 2014 at 02:31
    Unemployed over-50s will be offered "career reviews" and help with using computers as part of a government plan to get more older people int...
    Read more»
  • Dec. 20, 2014 at 02:24
    Police arrest the mother of seven of the eight children found dead in a home in Cairns, Australia.
    Read more»
  • Dec. 20, 2014 at 02:19
    Aerial photographs from the 1940s and 1950s are being used to probe the climate history of the Antarctic Peninsula.
    Read more»
  • Dec. 20, 2014 at 02:07
    How refugees in the northern US learn to walk on ice
    Read more»
  • Dec. 20, 2014 at 01:39
    Details are revealed of a network which attempted to defraud thousands of customers of the online travel agent Booking.com.
    Read more»
  • Dec. 20, 2014 at 01:34
    Martin Luther King had a dream of freedom. Can his biopic save Hollywood from censorship, asks the BBC's arts editor Will Gompertz
    Read more»
  • Dec. 20, 2014 at 01:29
    Kashmir's widows carry the scars of conflict
    Read more»
  • Dec. 20, 2014 at 01:25
    Virtual battle for eastern Ukraine
    Read more»
  • Dec. 20, 2014 at 01:19
    How 12 days of Christmas have become 12 pubs - in one night
    Read more»
  • Dec. 20, 2014 at 01:16
    Voters in Liberia are set to go to the polls in an election that was postponed because of the Ebola outbreak, with ex-footballer George Weah...
    Read more»
  • Dec. 20, 2014 at 01:11
    Cheerleading is usually seen as a young person's sport, but the Japan Senior Cheer Association is for women in their 60s and 70s.
    Read more»
  • Dec. 20, 2014 at 01:08
    Israel launches an air strike on an alleged Hamas site in Gaza, in the first such action since the declaration of a truce in August.
    Read more»
  • Dec. 20, 2014 at 01:00
    Charities warn patients are not being taught how to use potentially life-saving asthma inhalers and allergy auto-injectors correctly.
    Read more»
  • Dec. 20, 2014 at 00:49
    The timing of Alastair Cook's removal as England one-day captain was "naughty", according to Steve Harmison.
    Read more»
  • Dec. 19, 2014 at 23:57
    Colombia's Farc rebels have killed five soldiers in an ambush, the army says, hours before they are due to start an indefinite, unilateral c...
    Read more»
  • Dec. 19, 2014 at 23:53
    President Obama vows to respond to an alleged North Korean cyber-attack on Sony Pictures, but says cancelling a film release was "a mistake"...
    Read more»
  • Dec. 19, 2014 at 23:51
    Irish Foreign Minister Charlie Flanagan says he is hopeful that there will be a deal in Northern Ireland's cross-party talks early next week...
    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: