demo · v144

Checkout Fill

The motivating use case the WICG explainer kept coming back to: an address form where the user taps a single declarative control to populate city, state, postcode, and country from their location — no navigator.geolocation, no reverse-geocoder call from the page, no extra permission UX.

Behind a flag in 144. The polyfill fallback uses navigator.geolocation + a public reverse-geocoder. The declarative path is what the spec is trying to standardise.

<geolocation>: checking…

tap to fill from current location:

no location yet.

the API

<geolocation
  autofill="city state postcode country"
  precision="city">
  Use my location
</geolocation>

<script>
const el = document.querySelector("geolocation");
el.addEventListener("locate", (e) => {
  document.querySelector("#city").value = e.address.city;
  // etc.
});
</script>

see also