Send Geo-location from Browser

Create a button and log the current LAT/LON when the button is pressed:

<button id="send-location"> Send location</button>
document.querySelector('#send-location').addEventListener('click', () => {

    if (!navigator.geolocation) {

        return alert ('Geolocation not supported by Browser !')

    }
    
    navigator.geolocation.getCurrentPosition((position) => {

        console.log(position)

    })

console.log output

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.