Reputation: 3
i want to get the current latlng which is centered on the screen. like uber tells name of the place while we are moving the map on the screen it updates the value.
Upvotes: -1
Views: 5781
Reputation: 42
onCameraMove
you can get the center location of the screen
and then you can easily use setState to update the value
GoogleMap(
onCameraMove: (object) => {
setState(() {
latitude = object.target.latitude;
longitude = object.target.longitude;
})
},
Upvotes: 1
Reputation: 591
You can use the property onCameraMove
of GoogleMap
class.
GoogleMap(
onCameraMove: (CameraPosition position) {
print("Latitude: ${position.target.latitude}; Longitude: ${position.target.longitude}");
},
[...]
)
More info about GoogleMap and onCameraMove.
Upvotes: 1