ใช้เครื่องหมายเพื่อแสดงสถานที่เดียวบนแผนที่ หน้านี้แสดงวิธีเพิ่มเครื่องหมายลงในแผนที่โดยใช้โปรแกรมและโดยใช้ HTML
เพิ่มเครื่องหมายโดยใช้ HTML
หากต้องการเพิ่มเครื่องหมาย 3 มิติโดยใช้ 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>
เพิ่มเครื่องหมายโดยใช้โปรแกรม
หากต้องการเพิ่มเครื่องหมาย 3 มิติลงในแผนที่โดยใช้โปรแกรม ให้สร้าง 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.