Jump to content

MediaWiki:PlaceForm.js

From Costa Sano MediaWiki
Revision as of 12:20, 14 February 2026 by Mngr (talk | contribs) (Created page with "function lookupCoordinates() { const address = document.querySelector('[name="address"]').value; if (!address) { alert("Please enter an address first."); return; } const url = "https://nominatim.openstreetmap.org/search?format=json&q=" + encodeURIComponent(address); fetch(url) .then(response => response.json()) .then(data => { if (data.length === 0) { alert("No coordinates found for this ad...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
function lookupCoordinates() {
    const address = document.querySelector('[name="address"]').value;
    if (!address) {
        alert("Please enter an address first.");
        return;
    }

    const url = "https://nominatim.openstreetmap.org/search?format=json&q=" + encodeURIComponent(address);

    fetch(url)
        .then(response => response.json())
        .then(data => {
            if (data.length === 0) {
                alert("No coordinates found for this address.");
                return;
            }
            const lat = data[0].lat;
            const lon = data[0].lon;

            document.querySelector('[name="latitude"]').value = lat;
            document.querySelector('[name="longitude"]').value = lon;
        })
        .catch(error => alert("Error fetching coordinates: " + error));
}