alfonsocejudo / fluster

A geospatial point clustering library for Dart.
MIT License
68 stars 25 forks source link

Dynamically add or delete markers. #21

Open pr-1 opened 3 years ago

pr-1 commented 3 years ago

I have a list of LatLng values initially while creating the clusterManager.

I want to add more LatLng values dynamically. Currently I reinitialize the cluster manager with a new list of LatLng. So is this the correct way or is there something out of box available.

 final List<LatLng> _markerLocations = [
    LatLng(41.147125, -8.611249),
    LatLng(41.145599, -8.610691),
    LatLng(41.145645, -8.614761),
    LatLng(41.146775, -8.614913),
    LatLng(41.138344, -8.611236),
    LatLng(41.139813, -8.609381),
  ];
   /// Inits [Fluster] and all the markers with network images and updates the loading state.
  void _initMarkers() async {
    final List<MapMarker> markers = [];

    for (LatLng markerLocation in _markerLocations) {
      final BitmapDescriptor markerImage =
          await MapHelper.getMarkerImageFromUrl(_markerImageUrl);

      markers.add(
        MapMarker(
          id: _markerLocations.indexOf(markerLocation).toString(),
          position: markerLocation,
          icon: markerImage,
        ),
      );
    }

    _clusterManager = await MapHelper.initClusterManager(
      markers,
      _minClusterZoom,
      _maxClusterZoom,
    );

    await _updateMarkers();
  }

Once the above code is run I want to add more locations to the cluster


markerLocations.addAll([
 LatLng(41.146982, -8.615682),
    LatLng(41.140558, -8.611530),
    LatLng(41.138393, -8.608642),
    LatLng(41.137860, -8.609211),
]);

Now Do I have to reinitialize the clusterManager to reflect this change ? setState does not do any good.

This might be related to #20

timgrossmann commented 3 years ago

@alfonsocejudo We quickly chatted on Instagram before my account was taken down by facebook for https://github.com/timgrossmann/InstaPy.

Any chance we can discuss working on this issue? Let me know if you are open for finding a partnership for it. 😊 contact.timgrossmann@gmail.com

Thanks Alfonso

dayron9110 commented 2 years ago

News?

jonasPfeifhofer commented 2 years ago

Updates?