I am sorry for the question, but I am new to Flutter.
I simply created a Flutter app that shows a map from GoogleMap
, and then I added a Marker
to it.
This is the code:
class _GoogleMapExampleState extends State<GoogleMapExample> {
late GoogleMapController mapController;
Set<Marker> markers = {};
void zoomOnMarker(double lat, double lng) {
mapController
.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat, lng), 20));
}
@override
void initState() {
super.initState();
var marker = Marker(
markerId: MarkerId("123"),
position: LatLng(45, 9),
onTap: () {
zoomOnMarker(45, 9);
});
markers.add(marker);
}
@override
Widget build(BuildContext context) {
return GoogleMap(
initialCameraPosition:
const CameraPosition(target: LatLng(45, 9), zoom: 5),
onMapCreated: onMapCreated,
markers: markers.toSet(),
);
}
}
As soon as the user taps the marker, zoomOnMarker
function is called.
The problem is the animation of the zoom (here the video (I'm sorry for the quality but it's not easy recording from an Android)), the camera moves really weirdly, I'll explain: at first it zooms and only then it moves to the marker. The whole animation results strange.
I spent some hours trying other CameraUpdate
methods, but with no success.
Is it correct the zoomOnMarker
function? Are there other ways to to that?
Is there anyone who had the same issue?
Is this animation considered normal?