Utilizza gli indicatori per visualizzare singole località su una mappa. Questa pagina mostra come aggiungere un indicatore a una mappa in modo programmatico e utilizzando HTML.
Aggiungere un indicatore utilizzando l'HTML
Per aggiungere un indicatore 3D utilizzando HTML, aggiungi un elemento secondario gmp-marker-3d
all'elemento gmp-map-3d
. Il seguente snippet mostra l'aggiunta di indicatori a una pagina web:
<gmp-map-3d
mode="hybrid"
center="48.861000,2.335861"
heading="110"
tilt="67.5"
range="1000"
style="height:400px"
>
<gmp-marker-3d
position="48.861000,2.335861">
</gmp-marker-3d>
</gmp-map-3d>
Aggiungere un indicatore in modo programmatico
Per aggiungere un indicatore 3D a una mappa in modo programmatico, crea un nuovo Marker3DElement
,
passando le coordinate lat/lng
e un riferimento alla basemap, come mostrato in questo
esempio:
const marker = new Marker3DElement({
position: {lat: 47.6093, lng: -122.3402}, // (Required) Marker must have a lat/lng.
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.