reviews Uzyskaj klucz demonstracyjny Map: wypróbuj bezpłatnie wybrane funkcje Maps JavaScript API i Places UI Kit, korzystając z klucza demonstracyjnego Map – nie musisz podawać informacji rozliczeniowych.
Google używa technologii AI do tłumaczenia treści na Twój preferowany język. Tłumaczenia wygenerowane przez AI mogą zawierać błędy.
Nakładki to obiekty na mapie powiązane ze współrzędnymi geograficznymi, które poruszają się, gdy przeciągasz mapę lub powiększasz jej widok. Jeśli chcesz umieścić obraz na mapie, możesz użyć obiektu GroundOverlay.
Informacje o innych typach nakładek znajdziesz w artykule Rysowanie na mapie.
Dodawanie nakładki nawierzchni
Konstruktor obiektu GroundOverlay określa adres URL obrazu oraz jego LatLngBounds jako parametry. Obraz zostanie wyrenderowany na mapie, ograniczony do podanych granic i dopasowany za pomocą jej projekcji.
TypeScript
// This example uses a GroundOverlay to place an image on the map// showing an antique map of Newark, NJ.lethistoricalOverlay;functioninitMap():void{constmap=newgoogle.maps.Map(document.getElementById("map")asHTMLElement,{zoom:13,center:{lat:40.74,lng:-74.18},});constimageBounds={north:40.773941,south:40.712216,east:-74.12544,west:-74.22655,};historicalOverlay=newgoogle.maps.GroundOverlay("https://storage.googleapis.com/geo-devrel-public-buckets/newark_nj_1922-661x516.jpeg",imageBounds);historicalOverlay.setMap(map);}declareglobal{interfaceWindow{initMap:()=>void;}}window.initMap=initMap;
// This example uses a GroundOverlay to place an image on the map// showing an antique map of Newark, NJ.lethistoricalOverlay;functioninitMap(){constmap=newgoogle.maps.Map(document.getElementById("map"),{zoom:13,center:{lat:40.74,lng:-74.18},});constimageBounds={north:40.773941,south:40.712216,east:-74.12544,west:-74.22655,};historicalOverlay=newgoogle.maps.GroundOverlay("https://storage.googleapis.com/geo-devrel-public-buckets/newark_nj_1922-661x516.jpeg",imageBounds,);historicalOverlay.setMap(map);}window.initMap=initMap;
Aby usunąć nakładkę z mapy, wywołaj metodę setMap() nakładki, przekazując parametr null. Pamiętaj, że wywołanie tej metody nie powoduje usunięcia nakładki. Usunie nakładkę z mapy. Jeśli chcesz usunąć nakładkę,
usuń ją z mapy, a następnie ustaw dla niej wartość null.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-10-23 UTC."],[],["Ground overlays, images tied to latitude/longitude coordinates, are added to a map using the `GroundOverlay` constructor, specifying an image URL and `LatLngBounds`. The `setMap()` method then renders the image. Removing an overlay involves calling `setMap(null)` on the overlay object, which detaches it from the map but doesn't delete it. To delete the overlay it needs to be set to null. Example code is provided in TypeScript and JavaScript.\n"]]