Camera and Animations
This section of the SDK focuses on manipulating the camera position and performing animations on a map. The camera represents the viewpoint or perspective from which the map is viewed, and adjusting its position allows users to navigate and explore the map dynamically.
Camera Position
Initial position
Similar to the above quickstart example, we can set the initial camera position in the map view delegate, as is shown in below example code:
The center coordinates and camera zoom level is configurable during the initialization of the map view.
Set position
After the map view is initialized successfully, we can also move the map view camera position based on needs. An example is provided below:
Get position
We can also retrieve the current camera target position and camera zoom level if needed, the following code snippet shows how to achieve this:
Fit/Bind camera to a given shape
We can also form a polygon shape based on given coordinates, and fit the map view camera to the polygon shape, please refer to the below code snippet for example:
Listen to camera changes
We also allow listening to map view camera change via the following code example, just implement one of them in your delegate based on needs:
One thing to be aware of is, the later method will block the former one, so if you implement both of the methods, the first one will not be functional.
Restrict Camera
Besides the above camera operations, we can also customize whether to enable user actions on the map view. By default, the following actions are enabled, and we could disable part of them with the following code example: