הוספת אנימציות לנתיב המצלמה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בחירת פלטפורמה:
Android
iOS
אתם יכולים להוסיף אנימציות של נתיבי מצלמה למפה התלת-ממדית כדי לספק למשתמשים חוויה עשירה יותר. אנימציות של נתיב המצלמה יכולות להתקרב לנקודה במפה או להקיף אותה.
מעבר בטיסה אל
דוגמת הקוד הבאה מראה איך להנפיש את המצלמה כדי שתעבור לנקודה ספציפית במפה תלת-ממדית באמצעות הפעלת השיטה flyCameraTo
. כדי להשתמש בדוגמת הקוד הזו, צריך לפעול לפי ההוראות שבקטעים הגדרה והוספת מפה תלת-ממדית לאפליקציה כדי להגדיר את פרויקט Android Studio עם מפה תלת-ממדית בסיסית. אחר כך מוסיפים את הקוד הבא לקובץ MainActivity.kt
:
// Add imports and define constants
import com.google.android.gms.maps3d.model.latLngAltitude
const val EMPIRE_STATE_BUILDING_LATITUDE = 40.748233
const val EMPIRE_STATE_BUILDING_LONGITUDE = -73.985663
...
// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized
googleMap3D.flyCameraTo(
flyToOptions {
endCamera = camera {
center = latLngAltitude {
latitude = EMPIRE_STATE_BUILDING_LATITUDE
longitude = EMPIRE_STATE_BUILDING_LONGITUDE
altitude = 212.0 // in meters
}
heading = 34.0 // bearing in degrees
tilt = 67.0 // relative to vertical
range = 750.0 // distance away from the focal point in meters
roll = 0.0 // roll relative to horizontal
}
durationInMillis = 2_000
}
)
טיסה מסביב
דוגמת הקוד הבאה מראה איך להפעיל אנימציה של המצלמה כדי שתעוף סביב נקודה ספציפית במפה תלת-ממדית באמצעות הפעלת השיטה flyCameraAround
. כדי להשתמש בדוגמת הקוד הזו, צריך לפעול לפי ההוראות שבקטעים הגדרה והוספת מפה תלת-ממדית לאפליקציה כדי להגדיר את פרויקט Android Studio עם מפה תלת-ממדית בסיסית. לאחר מכן, מוסיפים את הקוד הבא לקובץ MainActivity.kt
:
// Add imports and define constants
import com.google.android.gms.maps3d.model.latLngAltitude
const val EMPIRE_STATE_BUILDING_LATITUDE = 40.748233
const val EMPIRE_STATE_BUILDING_LONGITUDE = -73.985663
...
// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized
googleMap3D.flyCameraAround(
flyAroundOptions {
center = camera {
center = latLngAltitude {
latitude = EMPIRE_STATE_BUILDING_LATITUDE
longitude = EMPIRE_STATE_BUILDING_LONGITUDE
altitude = 212.0
}
heading = 34.0
tilt = 67.0
range = 750.0
roll = 0.0
}
durationInMillis = 5_000
rounds = 1.0 // Number of rotations - can be fractional
}
)
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-31 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-31 (שעון UTC)."],[],[],null,["# Add camera path animations\n\nSelect platform: [Android](/maps/documentation/maps-3d/android-sdk/custom-camera-paths \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/custom-camera-paths \"View this page for the iOS platform docs.\")\n\n\u003cbr /\u003e\n\n| This product or feature is Experimental (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](/maps/launch-stages).\n\n\nYou can add camera paths animations to your 3D map to provide a more immersive\nexperience for your users. Camera path animations can fly to or fly around a point on the map.\n\nFly to\n------\n\n\nThe following code sample demonstrates how to animate the camera to fly to a specific point on a 3D map by calling\nthe [`flyCameraTo`](/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D#flyCameraTo(com.google.android.gms.maps3d.model.FlyToOptions))\nmethod. To use this code sample, follow the instructions in\n[Setup](/maps/documentation/maps-3d/android-sdk/setup) and\n[Add a 3D map to your app](/maps/documentation/maps-3d/android-sdk/add-a-3d-map) to set\nup your Android Studio project with a basic 3D map. Then, add the following code to the\n**`MainActivity.kt`** file: \n\n```kotlin\n// Add imports and define constants\nimport com.google.android.gms.maps3d.model.latLngAltitude\nconst val EMPIRE_STATE_BUILDING_LATITUDE = 40.748233\nconst val EMPIRE_STATE_BUILDING_LONGITUDE = -73.985663\n\n...\n \n// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized\ngoogleMap3D.flyCameraTo(\n flyToOptions {\n endCamera = camera {\n center = latLngAltitude {\n latitude = EMPIRE_STATE_BUILDING_LATITUDE\n longitude = EMPIRE_STATE_BUILDING_LONGITUDE\n altitude = 212.0 // in meters\n }\n heading = 34.0 // bearing in degrees\n tilt = 67.0 // relative to vertical\n range = 750.0 // distance away from the focal point in meters\n roll = 0.0 // roll relative to horizontal\n }\n durationInMillis = 2_000\n }\n)\n```\n\nFly around\n----------\n\n\nThe following code sample demonstrates how to animate the camera to fly around a specific point on a 3D map by\ncalling the [`flyCameraAround`](/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D#flyCameraAround(com.google.android.gms.maps3d.model.FlyAroundOptions))\nmethod. To use this code sample, follow the\ninstructions in\n[Setup](/maps/documentation/maps-3d/android-sdk/setup) and\n[Add a 3D map to your app](/maps/documentation/maps-3d/android-sdk/add-a-3d-map)\nto set up your Android Studio project with a basic 3D map. Then, add the\nfollowing code to the **`MainActivity.kt`** file: \n\n```kotlin\n// Add imports and define constants\nimport com.google.android.gms.maps3d.model.latLngAltitude\nconst val EMPIRE_STATE_BUILDING_LATITUDE = 40.748233\nconst val EMPIRE_STATE_BUILDING_LONGITUDE = -73.985663\n\n...\n\n// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized\ngoogleMap3D.flyCameraAround(\n flyAroundOptions {\n center = camera {\n center = latLngAltitude {\n latitude = EMPIRE_STATE_BUILDING_LATITUDE\n longitude = EMPIRE_STATE_BUILDING_LONGITUDE\n altitude = 212.0\n }\n heading = 34.0\n tilt = 67.0\n range = 750.0\n roll = 0.0\n }\n durationInMillis = 5_000\n rounds = 1.0 // Number of rotations - can be fractional\n }\n)\n```"]]