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

  • Nov. 01, 2014 at 14:39
    India's cricket board demands its West Indies counterpart pays up for pulling out of their tour of the country in October.
    Read more»
  • Nov. 01, 2014 at 14:38
    Tens of thousands of mourners attend the funeral of murdered South African football captain Senzo Meyiwa.
    Read more»
  • Nov. 01, 2014 at 14:34
    Burkina Faso military chiefs back Lt-Col Isaac Zida as transitional president, an army statement says, appearing to end confusion over who i...
    Read more»
  • Nov. 01, 2014 at 14:12
    Ed Miliband says that Labour would replace the House of Lords with an elected senate if the party won the general election in May 2015.
    Read more»
  • Nov. 01, 2014 at 13:39
    Islamic State militants have killed at least 50 members of an Iraqi tribe in a western province, officials say, after mass graves were found...
    Read more»
  • Nov. 01, 2014 at 13:37
    Egypt court sentences eight men to three years in prison for appearing in a video alleged to be of a gay marriage.
    Read more»
  • Nov. 01, 2014 at 12:37
    The government is urged to get an inquiry into historical child sex abuse moving quickly after Fiona Woolf stood down as its chairwoman.
    Read more»
  • Nov. 01, 2014 at 12:23
    Manchester United boss Louis van Gaal hopes his team can exploit Manchester City's dip in form at the Etihad on Sunday.
    Read more»
  • Nov. 01, 2014 at 12:04
    Canada suspends visa applications from countries in the grip of the Ebola outbreak, in a move similar to a much-criticised Australian plan.
    Read more»
  • Nov. 01, 2014 at 11:41
    Bangladesh is hit by major power blackouts after a power line connecting the country to India's electricity grid failed, reports say.
    Read more»
  • Nov. 01, 2014 at 10:30
    The use of police cautions - where those who commit minor offences are given a formal warning - is set to be scrapped in England and Wales.
    Read more»
  • Nov. 01, 2014 at 09:55
    Thousands gather in the Australian town of Albany to mark the centenary of the departure of the first Anzac troops in World War One.
    Read more»
  • Nov. 01, 2014 at 09:48
    Virgin founder Sir Richard Branson vows to continue his space tourism venture despite the SpaceShipTwo craft crashing in the US, killing a p...
    Read more»
  • Nov. 01, 2014 at 08:41
    Why did a drunken Delhi fight escalate into religious violence?
    Read more»
  • Nov. 01, 2014 at 06:34
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Nov. 01, 2014 at 05:48
    US President Barack Obama and First Lady Michelle welcome some special guests to the White House for a trick-or-treat Halloween celebration....
    Read more»
  • Nov. 01, 2014 at 03:33
    What is 'catchiest' hit single in British history?
    Read more»
  • Nov. 01, 2014 at 02:45
    The Uruguayan government announces the start of registration for licensed cannabis growers as part of its plan to legalise the drug.
    Read more»
  • Nov. 01, 2014 at 02:38
    Militant group Boko Haram denies claims by Nigeria's government that it has agreed to a ceasefire and will release 219 abducted girls.
    Read more»
  • Nov. 01, 2014 at 02:38
    The BBC's Lucas de Jong found one place in Singapore where interior designer Terry Goh has spent seven years making Hello Kitty the centre o...
    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: