Friday 12 July 2019

What is Geolocation API in HTML5 ?


GEOLOCATION API






{need to be familiar with basic JavaScript in order to understand and use API.}

In HTML5 , the geolocation API is used to obtain the user's geographical location.

Since this can compromise user privacy the option is not available unless the user approve it.



example of geolocation request on a website


The geolocation API's main method is get current position; which retrieves the current geographic location of user's device.

[navigator.geolocation.getCurrentPosition();]JavaScript

*PARAMETERS:


#ShowLocation(mandatory): Defines the callback method that retrieves location information.
#ErrorHandler(optional): Define the callback method that is invoked when an error occurs in processing the asynchronous call.
#Options(optional): Define a set of options for retrieving the location information.

The getCurrentPosition() method returns an object if it is successful. The latitude , longitude and accuracy properties are always returned.




*Presenting Data:

User location can be presented in two ways:

Geodetic & Civic.


  • The  geodetic way to describe position refers directly to latitude and longitude.
  • The Civic representation of location data is presented in a format that is more easily read and understand by the average  person.



{if you want to know more about this, then write in the comment box}

!!!THANKS!!!
Posted in:   |  
Share:

No comments:

Post a Comment