Open mohamed6996 opened 5 years ago
ugly workaround:
updateMarkers(Set<Marker> markers) {
setState(() {
_markers = markers.map(
(item) => item.infoWindow.title != '1'
? item
: () {
for (var i = 0; i < widget.locations.length; i++) {
if (
widget.locations[i].geoPosition == item.location.geoPosition
) {
return item.copyWith(
infoWindowParam: InfoWindow(
title: 'new title'
snippet: 'new snippet',
)
);
}
}
return item;
}()
).toSet();
});
}
ugly workaround:
updateMarkers(Set<Marker> markers) { setState(() { _markers = markers.map( (item) => item.infoWindow.title != '1' ? item : () { for (var i = 0; i < widget.locations.length; i++) { if ( widget.locations[i].geoPosition == item.location.geoPosition ) { return item.copyWith( infoWindowParam: InfoWindow( title: 'new title' snippet: 'new snippet', ) ); } } return item; }() ).toSet(); }); }
Good work, @felpsio - I've tweaked your solution for my own use case where I have approximately 3000 markers and works fine...
_updateMarkers(Set<Marker> markers) {
//TODO see https://github.com/giandifra/clustering_google_maps/issues/15
setState(() {
_markers = markers
.map((clusterMarker) => () {
for (var i = 0; i < widget.markers.length; i++) {
var marker = widget.markers[i];
if (marker.position == clusterMarker.position) {
return clusterMarker.copyWith(
infoWindowParam: marker.infoWindow,
iconParam: marker.icon,
);
}
}
return clusterMarker;
}())
.toSet();
});
}
Currently, info window displays the title as count id. I need to to display q custom title.