arbiter
arbiter

Reputation: 451

Add multiple marker lists to set in Flutter GoogleMaps

     Container(
                            child: GoogleMap(
                              initialCameraPosition: CameraPosition(
                                  target: LatLng(currentPosition.latitude,
                                      currentPosition.longitude),
                                  zoom: 16.0),
                              zoomGesturesEnabled: true,
                              //still need somewhere to display other set of created markers
                              markers: Set<Marker>.of(markers),

So as you can see, here is a snippet of Google Maps on Flutter. What I am looking to do is add multiple sets of marker lists, for example I have another List of markers that I would add, but I can't seem to figure out if it's even possible

    markers: Set<Marker>.of(markers),

Outside of the build method I have another list of markers that would need to be added to the same Google Map:

    final Set<Marker> _secondMarkers= {};

this would need to be added here I presume, but it doesn't allow for multiple lists. Is there another simple solution for this? I've been racking my brain for hours now, tried .add to the set, but it doesn't allow it. Is there a clean way to do this, or should I just try another solution?

Upvotes: 2

Views: 894

Answers (1)

Aymen TLILI
Aymen TLILI

Reputation: 154

you can add to the Set if you add to the list of markers in the setState methode.

Upvotes: 2

Related Questions