Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Geolocation API in HTML5

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 225
    Comment on it

    HTML5 Provides new feature of geolocation API which can help user to find his current location and share the location to the web site.

    It works with the javascript which capture the latitude and longitude of the user. It works with the global navigator object that is a geolocation object. It can be created by following

     var geolocation = navigator.geolocation; 
    

    The geolocation object provides these methods 1. getCurrentPosition() to get the current location of the user. 2. watchPosition() to periodic updates of the current location of device. 3. clearWatch() to cancel the watchPosition.

     function geolocation(){
     var geolocation = navigator.geolocation; 
    geolocation.getCurrentPosition(showLocation, errorHandler);
     } 
    

    showLocation and errorHandler are callback methods that is used to get actual position. These method are called with Position object that stores the complete information. The location is specified in the geographical coordinates.

     function showLocation(position){
     var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
     } 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: