אפשר להשתמש בסמנים כדי להציג מיקומים בודדים במפה. בדף הזה מוסבר איך להוסיף סמן למפה באופן פרוגרמטי וגם באמצעות HTML.
הוספת סמן באמצעות HTML
כדי להוסיף סמן תלת-ממדי באמצעות HTML, מוסיפים רכיב צאצא gmp-marker-3d
לרכיב gmp-map-3d
. קטע הקוד הבא מראה איך מוסיפים סמנים לדף אינטרנט:
<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>
הוספת סמן באופן פרוגרמטי
כדי להוסיף סמן תלת-ממדי למפה באופן פרוגרמטי, יוצרים Marker3DElement
חדש, מעבירים קואורדינטות של lat/lng
והפניה למפת הבסיס, כמו בדוגמה הזו:
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.