Skip to content

Instantly share code, notes, and snippets.

@m3l1nd4
Created April 1, 2021 03:43
Show Gist options
  • Save m3l1nd4/6b73713546ea36b2c5548b6782bab7c5 to your computer and use it in GitHub Desktop.
Save m3l1nd4/6b73713546ea36b2c5548b6782bab7c5 to your computer and use it in GitHub Desktop.
// Gives back the current location & adds a marker to the map
// onSuccess callback accepts a Position object, which contains the current coordinates
// onError callback receives a PositionError object
function currentLocation(map) {
navigator.geolocation.getCurrentPosition(function (position) {
onSuccess(map, position);
document.getElementById("shop-location").value = position.coords.latitude + " " + position.coords.longitude;
}, onError);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment