Cómo agregar un marcador a un mapa 3D

Selecciona la plataforma: Android iOS JavaScript

Usa marcadores para mostrar ubicaciones individuales en un mapa. Esta página muestra cómo agregar un marcador a un mapa tanto con HTML como de forma programática.

Cómo agregar un marcador con HTML

Para agregar un marcador 3D con HTML, agrega un elemento secundario gmp-marker-3d al elemento gmp-map-3d. En el siguiente fragmento, se muestra cómo agregar marcadores a una página 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>

Cómo agregar un marcador de forma programática

Para agregar un marcador 3D a un mapa de forma programática, crea un nuevo objeto Marker3DElement, pasando coordenadas lat/lng y una referencia al mapa base, como se muestra en este ejemplo:

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.

Próximos pasos