Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prompt location sharing permission in browser using JavaScript?

how do I prompt location share permission to user using JavaScript. For example whenever we visit google maps browser automatically asks for share location. My Aim is to prompt user for permission to share location. As I'm working in tracking module in AngularJS though i need to prompt user for permission in google Chrome. Thank you


1 Answers

You can use the function like this. Calling this function will raise the popup.

navigator.geolocation.getCurrentPosition(function(position) {
  yourFunction(position.coords.latitude, position.coords.longitude);
});

When position is available, yourFunction will get executed.

like image 54
Tarafder Ashek E Elahi Avatar answered Oct 27 '25 10:10

Tarafder Ashek E Elahi