I am using browser API for geolocation like below (codes written below are just for demo)
$(function () {
$('#link-getlocation').click(function () {
navigator.geolocation.getCurrentPosition(function(loc){
alert(loc.coords.latitude + ', ' + loc.coords.longitude);
});
});
});
<a href="javascript:" id="link-getlocation">Get Location</a>
My question is how browser detects the location coordinates of the user
It depends on the capabilities of the client browser.
Most of these depend on OS and browser support and can vary between browsers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.