सुविधा के बारे में जानकारी
ओवरले, मैप पर वे ऑब्जेक्ट होते हैं जो अक्षांश/देशांतर के निर्देशांकों से जुड़े होते हैं. इसलिए, जब आप मैप को खींचें या ज़ूम करें, तो वे हिलने-डुलने लगें. अगर आपको मैप पर कोई इमेज डालनी है, तो आप किसी 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); }