Yes, it is possible to modify the camera zoom point in Flutter using the CameraPosition
class's zoom
parameter. The zoom
parameter ranges from 0.0 to 21.0, where 0.0 represents the furthest zoom level (i.e., the entire world map), and 21.0 represents the closest zoom level (i.e., street-level).
To modify the camera zoom point, you can create a new CameraPosition
object with the desired zoom level and set it as the CameraPosition
for your GoogleMap
widget:
GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(37.7749, -122.4194),
zoom: 15.0, // Set initial zoom level here
),
onMapCreated: (GoogleMapController controller) {
// ...
},
)
Then, you can modify the zoom level dynamically by creating a new CameraPosition
object with the updated zoom level and calling the animateCamera
method on your GoogleMapController
:
GoogleMapController controller; // This should be set in `onMapCreated`
void _updateZoom(double newZoom) {
CameraPosition newCameraPosition = CameraPosition(
target: controller.cameraPosition.target,
zoom: newZoom,
);
controller.animateCamera(CameraUpdate.newCameraPosition(newCameraPosition));
}
Asked: 2023-05-19 09:52:31 +0000
Seen: 14 times
Last updated: May 19 '23