परिचय
ओवरले, मैप पर मौजूद ऐसे ऑब्जेक्ट होते हैं जो अक्षांश/देशांतर निर्देशांकों से जुड़े होते हैं. इसलिए, मैप को खींचने और छोड़ने या ज़ूम करने पर, ये ऑब्जेक्ट भी मूव होते हैं. अगर आपको मैप पर कोई इमेज दिखानी है, तो GroundOverlay ऑब्जेक्ट का इस्तेमाल किया जा सकता है.
अन्य तरह के ओवरले के बारे में जानकारी पाने के लिए, मैप पर ड्रॉइंग करना लेख पढ़ें.
ग्राउंड ओवरले जोड़ना
GroundOverlay के लिए कंस्ट्रक्टर, इमेज के यूआरएल और इमेज के LatLngBounds को पैरामीटर के तौर पर तय करता है. इमेज को मैप पर रेंडर किया जाएगा. साथ ही, इसे तय की गई सीमाओं के अंदर रखा जाएगा और मैप के प्रोजेक्शन का इस्तेमाल करके दिखाया जाएगा.
TypeScript
// This example uses a GroundOverlay to place an image on the map // showing an antique map of Newark, NJ. let historicalOverlay; function initMap(): void { const map = new google.maps.Map( document.getElementById("map") as HTMLElement, { zoom: 13, center: { lat: 40.74, lng: -74.18 }, } ); const imageBounds = { north: 40.773941, south: 40.712216, east: -74.12544, west: -74.22655, }; historicalOverlay = new google.maps.GroundOverlay( "https://storage.googleapis.com/geo-devrel-public-buckets/newark_nj_1922-661x516.jpeg", imageBounds ); historicalOverlay.setMap(map); } declare global { interface Window { initMap: () => void; } } window.initMap = initMap;
JavaScript
// This example uses a GroundOverlay to place an image on the map // showing an antique map of Newark, NJ. let historicalOverlay; function initMap() { const map = new google.maps.Map(document.getElementById("map"), { zoom: 13, center: { lat: 40.74, lng: -74.18 }, }); const imageBounds = { north: 40.773941, south: 40.712216, east: -74.12544, west: -74.22655, }; historicalOverlay = new google.maps.GroundOverlay( "https://storage.googleapis.com/geo-devrel-public-buckets/newark_nj_1922-661x516.jpeg", imageBounds, ); historicalOverlay.setMap(map); } window.initMap = initMap;
ग्राउंड ओवरले हटाना
मैप से किसी ओवरले को हटाने के लिए, ओवरले के setMap() तरीके को कॉल करें और null को पास करें. ध्यान दें कि इस तरीके को कॉल करने से, ओवरले नहीं मिटता. यह मैप से ओवरले को हटा देता है. अगर आपको ओवरले को मिटाना है, तो उसे मैप से हटाएं. इसके बाद, ओवरले को null पर सेट करें.
function removeOverlay() { historicalOverlay.setMap(null); }