Get device location with Javascript @netcreed #shorts #javascript

preview_player
Показать описание
To retrieve a users coordinate with JavaScript you have to use the `geolocation` api. The Geolocation api exist on the navigator object.

First we have to check if the Geolocation object is available on the navigator.

If it does, we call the getCurrentPosition method on the Geolocation object.

This function accepts two arguments, the first is a callback function that will handle a success condition,

this function can accept a object which contains the users current position. We destructure this object to get the users coordinates.

Typically we would use a reverse geocoding api to get the users address from the coordinates.

The second argument we can pass to the getCurrentPosition method is an error handler function.

I hope this video was helpful!

#javascript #typescript #geolocation #coding #programming #webdevelopment #software #navigator #browser
Рекомендации по теме
join shbcf.ru