Annuncio: a breve su Google Maps Platform saranno disponibili nuovi stili della mappa di base. Questo aggiornamento dello stile della mappa include una nuova tavolozza dei colori predefinita, indicatori modernizzati e miglioramenti alle esperienze e all'usabilità delle mappe. Tutti gli stili di mappa verranno aggiornati automaticamente a marzo 2025. Per ulteriori informazioni sulla disponibilità e su come attivare in anteprima questa funzionalità, consulta Nuovo stile di mappa per Google Maps Platform.
Gli overlay sono oggetti sulla mappa legati alle coordinate di latitudine/longitudine, quindi si spostano quando trascini la mappa o ne aumenti lo zoom. Se vuoi inserire un'immagine su una mappa, puoi utilizzare un oggetto GroundOverlay.
Il costruttore di un
GroundOverlay specifica un URL di un'immagine
e il LatLngBounds dell'immagine come parametri. L'immagine verrà visualizzata sulla mappa, limitata ai limiti specificati e conforme alla proiezione della mappa.
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;
Per rimuovere un overlay da una mappa, chiama il metodo setMap() dell'overlay, passando null. Tieni presente che
la chiamata a questo metodo non elimina l'overlay. Rimuove
l'overlay dalla mappa. Se invece vuoi eliminare l'overlay, deve rimuoverlo dalla mappa e impostare l'overlay stesso su null.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-03-13 UTC."],[[["Ground overlays let you place images on a map tied to latitude/longitude coordinates."],["You can add a ground overlay using the `GroundOverlay` object, specifying the image URL and boundaries."],["To remove a ground overlay from the map, call `setMap(null)` on the overlay object."],["Removing an overlay from the map doesn't delete it; to delete it, set the overlay object to `null` after removing it from the map."]]],["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"]]