flutter dart implementation
a dart implementation of leaflet.markercluster for flutter apps. this is a plugin for flutter_map package.
usage
add flutter_map and flutter_map_marker_cluster to your pubspec:
dependencies:
flutter_map: any
flutter_map_marker_cluster: any # or the latest version on pub
add it in you fluttermap and configure it using markerclustergrouplayeroptions
.
widget build(buildcontext context) {
return fluttermap(
options: new mapoptions(
plugins: [
markerclusterplugin(),
],
),
layers: [
tilelayeroptions(
urltemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
markerclusterlayeroptions(
maxclusterradius: 120,
height: 40,
width: 40,
fitboundsoptions: fitboundsoptions(
padding: edgeinsets.all(50),
),
markers: markers,
polygonoptions: polygonoptions(
bordercolor: colors.blueaccent,
color: colors.black12,
borderstrokewidth: 3),
builder: (context, markers) {
return floatingactionbutton(
child: text(markers.length.tostring()),
onpressed: null,
);
},
),
],
);
}
run the example
see the example/
folder for a working example app.
Comments are closed.