Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function success(position) {
- const latitude = position.coords.latitude;
- const longitude = position.coords.longitude;
- console.log(latitude+', '+longitude);
- }
- function error() {
- console.log('Unable to retrieve your location');
- }
- if (!navigator.geolocation) {
- console.log('Geolocation is not supported by your browser');
- } else {
- navigator.geolocation.getCurrentPosition(success, error);
- }
- // result:
- > 12.12345667, 12.34567890
Advertisement
Add Comment
Please, Sign In to add comment