Closed SuMitVayuz closed 3 years ago
How many markers do you have on average when your app crashes ?
I think you may not be using the library correctly, the updateMarkers
method is therefore called too many times, causing the application to crash.
The app was crashing when there were about 500-600 markers. Anyway, I think the issue was calling updateMarkers too many times. One more mistake was that updateMarker was called in _onCameraMove. After doing a bit of refactoring, now it is working fine.
As the number of markers increases the map begins to lag and unresponsive. And finally, the app crashes.
/// my map GoogleMap( mapToolbarEnabled: false, zoomControlsEnabled: false, onMapCreated: _onMapCreated, myLocationEnabled: false, myLocationButtonEnabled: false, minMaxZoomPreference: MinMaxZoomPreference(1.0, 14.0), initialCameraPosition: CameraPosition( target: widget.initialPosition, zoom: _defaultZoom, ), markers: _updateMarker( Provider.of(context).userDetailsList),
onCameraMove: _onCameraMove,
onCameraIdle: _onCameraIdle,
),
/// update marker Set _updateMarker(List userDetailsList) {
_manager.setItems(<ClusterItem>[
for (UserDetails userDetails in userDetailsList)
ClusterItem(LatLng(userDetails.lat, userDetails.long),
item: Place(name: userDetails.name))
]);
_manager.updateMap();
return _markers;
}
/// cluster manager ClusterManager _initClusterManager() { return ClusterManager(items, _updateMarkers,
markerBuilder: _markerBuilder, initialZoom: _defaultZoom);
}
List<ClusterItem> items = [];
Not able to figure out what's causing the issue, can it be the package issue or flutter issue? Any help will be appreciated.