Google Maps LatLon Extractor

Adds a small floating button to Google Maps that extracts and copies the latitude and longitude from the current URL.

2025-10-31 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Google Maps LatLon Extractor
// @namespace    gmaps-latlon
// @version      1.0
// @description  Adds a small floating button to Google Maps that extracts and copies the latitude and longitude from the current URL.
// @author       bekkibau
// @license      MIT
// @match        https://www.google.com/maps/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create floating button
    const btn = document.createElement('button');
    btn.textContent = 'Get LatLon';
    Object.assign(btn.style, {
        position: 'fixed',
        top: '80px',
        right: '20px',
        zIndex: 9999,
        background: '#fff',
        color: '#000',
        border: '1px solid #ccc',
        borderRadius: '8px',
        padding: '6px 10px',
        cursor: 'pointer',
        boxShadow: '0 2px 6px rgba(0,0,0,0.3)',
        fontSize: '14px'
    });
    document.body.appendChild(btn);

    // Extract latitude and longitude from the URL
    const getLatLon = () => {
        const match = location.href.match(/@(-?\d+\.\d+),(-?\d+\.\d+)/);
        return match ? { lat: match[1], lon: match[2] } : null;
    };

    // Show popup with copy button
    const showPopup = ({ lat, lon }) => {
        const popup = document.createElement('div');
        Object.assign(popup.style, {
            position: 'fixed',
            top: '120px',
            right: '20px',
            background: '#fff',
            color: '#000',
            border: '1px solid #ccc',
            borderRadius: '8px',
            padding: '10px',
            zIndex: 9999,
            boxShadow: '0 2px 8px rgba(0,0,0,0.3)',
            fontSize: '13px'
        });
        popup.innerHTML = `
            <div><b>Latitude:</b> ${lat}</div>
            <div><b>Longitude:</b> ${lon}</div>
            <button id="copyLatLon" style="
                margin-top:6px;
                background:#4285f4;
                color:#fff;
                border:none;
                border-radius:5px;
                padding:4px 8px;
                cursor:pointer;">Copy</button>
        `;
        document.body.appendChild(popup);

        popup.querySelector('#copyLatLon').onclick = () => {
            navigator.clipboard.writeText(`${lat}, ${lon}`);
            popup.querySelector('#copyLatLon').textContent = 'Copied!';
            setTimeout(() => popup.remove(), 1500);
        };
    };

    // Handle button click
    btn.addEventListener('click', () => {
        const coords = getLatLon();
        if (coords) showPopup(coords);
        else alert('Could not find coordinates in URL.');
    });
})();