logo
logo
Sign in

How To Add HTML5 Geolocation To Your Web App?

avatar
Vladimir Sidorenko

These include navigators and maps, taxi and weather-forecast services, various rental and booking services like Uber or Airbnb, even messengers – all of them are using geolocation to provide more convenient, friendly and fast services.

Geolocation saves time in such cases by detecting the current location automatically without any additional user input or scrolling long lists in an effort to find necessary city.

As an example we are going to create small web app which will be able to calculate the shortest route between detected user’s location (point A) and predefined destination (point B) using Google Maps API.

This is html5 geolocation service which is supported by all modern web browsers (even IE!)

This method is used to define the current location of a user.

console.log("Latitude: " + position.coords.latitude + ", Longitude: " + position.coords.longitude)

collect
0
avatar
Vladimir Sidorenko
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more