
דוגמת הקוד הבאה ממחישה איך מוסיפים סמן בסיסי למפה תלת-ממדית באמצעות קריאה ל-method addMarker
. כדי להשתמש בדוגמת הקוד הזו, צריך לפעול לפי ההוראות בקטע הגדרה ובקטע הוספת מפה תלת-ממדית לאפליקציה כדי להגדיר את הפרויקט ב-Android Studio עם מפה תלת-ממדית בסיסית. לאחר מכן מוסיפים את הקוד הבא לקובץ MainActivity.kt
:
// Add imports import com.google.android.gms.maps3d.model.latLngAltitude ... // Add to the onMap3DViewReady method, after the googleMap3D object has been initialized googleMap3D.setMapMode(Map3DMode.SATELLITE) googleMap3D.setCamera( camera { center = latLngAltitude { latitude = 52.51974795 longitude = 13.40715553 altitude = 150.0 } heading = 252.7 tilt = 79.0 range = 1500.0 } ) // Add a marker using absolute altitude positioning googleMap3D.addMarker(markerOptions { position = latLngAltitude { latitude = 52.519605780912585 longitude = 13.406867190588198 altitude = 150.0 } label = "Absolute (150m)" altitudeMode = AltitudeMode.ABSOLUTE isExtruded = true isDrawnWhenOccluded = true collisionBehavior = CollisionBehavior.REQUIRED_AND_HIDES_OPTIONAL })