setPoints method

Future<void> setPoints(
  1. List<LatLng> points
)

Updates the map with a new list of points to be clustered.

Implementation

Future<void> setPoints(List<LatLng> points) async {
  final geojson = {
    'type': 'FeatureCollection',
    'features': points
        .map(
          (p) => {
            'type': 'Feature',
            'geometry': {
              'type': 'Point',
              'coordinates': [p.longitude, p.latitude],
            },
            'properties': {},
          },
        )
        .toList(),
  };

  if (!_isInitialized) {
    await _initClustering(geojson);
    _isInitialized = true;
  } else {
    await _controller.setGeoJsonSource(sourceId, geojson);
  }
}