Preview:
const findLocation = () => {
  const status = document.querySelectorAll('.status')

  const success = (position) => {
    console.log(position)
  }

  const error = () => {
    status.textContent = 'unable to get location'
  }

  navigator.geolocation.getCurrentPosition(success, error, {
    maximumAge: '10000',
    enableHighAccuracy: true,
  })
}

window.addEventListener('load', findLocation)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter