3D मैप में मार्कर जोड़ना

प्लैटफ़ॉर्म चुनें: Android iOS JavaScript

मैप पर किसी एक जगह को दिखाने के लिए, मार्कर का इस्तेमाल करें. इस पेज पर, प्रोग्रामैटिक तरीके से और एचटीएमएल का इस्तेमाल करके, मैप में मार्कर जोड़ने का तरीका बताया गया है.

एचटीएमएल का इस्तेमाल करके मार्कर जोड़ना

एचटीएमएल का इस्तेमाल करके, 3D मार्कर जोड़ने के लिए, gmp-map-3d एलिमेंट में gmp-marker-3d चाइल्ड एलिमेंट जोड़ें. यहां दिए गए स्निपेट में, वेब पेज पर मार्कर जोड़ने का तरीका दिखाया गया है:

<html>
    <head>
        <title>3D Marker HTML</title>
        <link rel="stylesheet" type="text/css" href="./style.css" />
        <script
            async
            src="https://maps.googleapis.com/maps/api/js?loading=async&key=AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8&libraries=maps3d"></script>
    </head>
    <body>
        <gmp-map-3d
            center="40.7489,-73.9680,0"
            heading="315"
            tilt="65"
            range="800"
            mode="SATELLITE">
            <gmp-marker position="40.7489,-73.9680" title="UN Headquarters">
                <div class="custom-marker">
                    United Nations Secretariat Building
                </div>
            </gmp-marker>
        </gmp-map-3d>
    </body>
</html>

प्रोग्रामैटिक तरीके से मार्कर जोड़ना

प्रोग्रामैटिक तरीके से मैप में 3D मार्कर जोड़ने के लिए, नया Marker3DElement बनाएं. इसमें lat/lng कोऑर्डिनेट और बेस मैप का रेफ़रंस पास करें. जैसा कि इस उदाहरण में दिखाया गया है:

async function init() {
    // Make sure the Marker3DElement is included.
    const { Map3DElement, Marker3DElement } =
        await google.maps.importLibrary('maps3d');

    const map = new Map3DElement({
        center: { lat: 37.4239163, lng: -122.0947209, altitude: 0 },
        tilt: 67.5,
        range: 1000,
        mode: 'SATELLITE',
        gestureHandling: 'COOPERATIVE',
    });

    const marker = new Marker3DElement({
        position: { lat: 37.4239163, lng: -122.0947209, altitude: 50 }, // (Required) Marker must have a lat / lng, but doesn't need an altitude.
        altitudeMode: 'ABSOLUTE', // (Optional) Treated as CLAMP_TO_GROUND if omitted.
        extruded: true, // (Optional) Draws line from ground to the bottom of the marker.
        label: 'Basic Marker', // (Optional) Add a label to the marker.
    });

    map.append(marker); // The marker must be appended to the map.
    document.body.append(map);
}

void init();

अगले चरण