SIGN UP MEMBER LOGIN:    
Resource

Geolocation into HTML 5

Mahesh Chand Resources Dec 07, 2011
How to implement geolocation into a web application using HTML 5.

According to the W3C specification, geolocation is an "… API that provides scripted access to geographical location information associated with the hosting device." Because geolocation is a built-in API, all you need to get started is a browser that supports it. At the time of this writing, Internet Explorer 9 (including Internet Explorer 9 on Windows Phone 7.5,  code-named "Mango"),as well as the current versions of Chrome, Firefox, Safari and Opera, all support geolocation, so the specification is not only broadly supported, but probably available to a large segment of your user base.

The Geolocation API lives in the global "navigator" object in JavaScript (window.navigator.geolocation). It provides two ways to work with location services: one-shot position requests and repeated position updates. For one-shot requests, use the getCurrentPosition method, like so:

  1. navigator.geolocation.getCurrentPosition(function(position) {
  2.        var coordinates = position.coords;
  3.        console.log("Your latitude: " + coordinates.latitude + " and longitude:
  4.          " + coordinates.longitude + " (Accuracy of:
  5.          " + coordinates.accuracy + " meters)");
  6. }, errorHandler, { maximumAge: 100, timeout: 6000, enableHighAccuracy: true});


Read full article here
share this resource :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Sponsored by
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor