Nani samireddy
Nani samireddy

Reputation: 3

How to get the current camera position latlng in google maps flutter

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

Answers (2)

David Samir
David Samir

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

alecsam
alecsam

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

Related Questions