Nihal Gurrala
Nihal Gurrala

Reputation: 79

Programmatically selecting a marker on google map flutter

We have to show the marker InfoWindow and increase the size of the marker to show the focus of the highlighted location programmatically. How can we achieve this in flutter google maps? Example image

Upvotes: 1

Views: 2837

Answers (4)

Lightwaxx
Lightwaxx

Reputation: 755

If you need to open it outside the onMapCreated method after creating the map, you can still call the controller as below. Noted that _controller needs to be initialized.

final GoogleMapController mapcontroller = await _controller.future;
mapcontroller.showMarkerInfoWindow(MarkerId(MARKER_ID));

Upvotes: 0

Edimar Martins
Edimar Martins

Reputation: 3167

To select a marker do:

maker.onTap();

To show marker InfoWindow, do:

googleMapController
            .animateCamera(CameraUpdate.newLatLngBounds(bounds, 45.0))
            .then((_) async {
          await Future.delayed(Duration(seconds: 1));
          googleMapController.showMarkerInfoWindow(markerId);
    });

Upvotes: 0

Tim Kariuki
Tim Kariuki

Reputation: 2030

You can use GoogleMapController to show the info window.

googleMapController.showMarkerInfoWindow(markerId);

Upvotes: 2

Lucien Theron
Lucien Theron

Reputation: 413

Hi its not possible at the moment but there are issues made for it: https://github.com/flutter/flutter/issues/29899 and https://github.com/flutter/flutter/issues/33481.

Upvotes: 0

Related Questions