配置相机控件
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
用户可以在地图上使用手势来控制相机的缩放、倾斜、位置和旋转。
您还可以通过编程方式配置摄像头。
镜头位置
地图视图被建模成一个俯视 3D 空间中特定点的相机。
相机的位置和方向(以及地图的渲染)由下列属性指定:中心(相机所对准的纬度/经度/海拔高度位置)、方向、倾斜角度、距离和滚动角度。
中心(纬度/经度/海拔高度)
中心定义了相机正在观察的 3D 空间中的特定点。
这是使用纬度、经度和海拔值指定的。这样,您就可以在三维空间中精确定位相机的焦点。
纬度可以介于 -90 度(含)和 90 度(含)之间。不在此范围内的值会被调整为此范围内最接近的值。例如,如果将纬度指定为 100,系统会将该值设为 90。经度范围为 -180 度(含)到 180 度(含)。海拔高度以米为单位,表示高于海平面的高度。
标题
相机朝向指定了相机将指向的方向,以相对于正北方的顺时针角度来表示。北对应于 0 度,东对应于 90 度,南对应于 180 度,西对应于 270 度。此属性用于确定相机绕中心点垂直轴的朝向。
倾斜
倾斜度是指相机相对于垂直轴的角度,以度为单位。倾斜度为 0 度表示相机正对地球(天底)。倾斜度为 90 度表示相机水平指向方位指定的方向。
Range
范围定义了相机自身位置与所拍摄的中心点之间的距离(以米为单位)。范围可以从 0 米(非常近的特写)到 6, 300 万米不等,从而实现从非常近的特写到真正全球视角的各种视图。这实际上控制着地图的“放大”或“缩小”程度。
旋转
滚转角用于设置相机相对于地平线的角度,以度为单位。此形参可用于创建飞行模拟期间的倾斜等效果,甚至可以围绕观看轴旋转相机,实现完整的桶滚效果。
控制相机
以下代码示例演示了如何以编程方式控制相机。
Swift
public static var sanFrancisco: Camera = .init(
latitude: 37.7845812,
longitude: -122.3660241,
altitude: 585,
heading: 288.0,
tilt: 75.0,
roll: 0.0,
range: 100)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[],[],null,["# Configure camera controls\n\nSelect platform: [Android](/maps/documentation/maps-3d/android-sdk/configure-camera-controls \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/configure-camera-controls \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/3d/map-controls \"View this page for the JavaScript 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\nUsers can control the zoom, tilt, position, and rotation of the camera using gestures on the map.\nYou can also configure the camera programmatically.\n\nThe Camera Position\n-------------------\n\nThe map view is modeled as a **camera** looking at a specific point in a 3D space.\nThe position and orientation of the camera (and hence the rendering of the map) are specified by\nthe following properties: center (a latitude/longitude/altitude location the camera is looking\nat), heading, tilt, range, and roll.\n\n### Center (Latitude/Longitude/Altitude)\n\nThe **center** defines the specific point in 3D space that the camera is observing.\nThis is\nspecified using values for latitude, longitude, and altitude. This allows for precise\npositioning of the camera's focal point in three dimensions.\n\n\nThe latitude can be between -90 and 90 degrees, inclusive. Values\nabove or below this range will be clamped to the nearest value within this range. For example,\nspecifying a latitude of 100 will set the value to 90. Longitude\nranges between -180 and 180 degrees, inclusive. Altitude is specified in meters above\nsea level.\n\n### Heading\n\nThe camera **heading** specifies the direction the camera will point, measured in\ndegrees clockwise from true North. North corresponds to 0 degrees, East to 90 degrees, South to\n180 degrees, and West to 270 degrees. This determines the orientation of the camera around the\nvertical axis of the [center point](#center_location).\n\n### Tilt\n\nThe **tilt** specifies the angle of the camera with respect to the vertical axis,\nmeasured in degrees. A tilt of 0 degrees means the camera is pointing straight down towards the\nEarth ([nadir](https://en.wikipedia.org/wiki/Nadir)). A tilt of 90\ndegrees means the camera is pointed horizontally in the direction\nspecified by the [heading](#heading_orientation).\n\n### Range\n\nThe **range** defines the distance in meters between the camera's own position and\nthe [center point](#center_location) it is looking at. The range can vary from zero\nmeters (very close up) up to sixty-three million meters, allowing for views from very close up all\nthe way to a truly global perspective. This effectively controls how \"zoomed in\" or \"zoomed out\"\nthe map appears.\n\n### Roll\n\n\nThe **roll** sets the angle of the camera with respect to the horizon,\nmeasured in degrees. This parameter can be used to create effects like banking during flight\nsimulations or even a full barrel roll, rotating the camera around its viewing axis.\n\nControlling the camera\n----------------------\n\nThe following code sample demonstrates how to control the camera programmatically. \n\n### Swift\n\n```swift\npublic static var sanFrancisco: Camera = .init(\n latitude: 37.7845812,\n longitude: -122.3660241,\n altitude: 585,\n heading: 288.0,\n tilt: 75.0,\n roll: 0.0,\n range: 100)\n\n \n```"]]