dash-leaflet icon indicating copy to clipboard operation
dash-leaflet copied to clipboard

dl.MarkerClusterGroup triggers the error, version dash-leaflet 1.0.15

Open LarBlu0001 opened this issue 4 months ago • 0 comments

I tried to implement clustering using dash-leaflet. The error I had: AttributeError: module 'dash_leaflet' has no attribute 'MarkerClusterGroup' import dash import dash_leaflet as dl import dash_leaflet.express as dlx from dash import html

Dummy marker data (Melbourne region)

lats = [-37.81, -37.80, -37.82, -37.83, -37.84] lons = [144.96, 144.95, 144.97, 144.98, 144.99]

Create GeoJSON features

geojson_data = dlx.dicts_to_geojson([ dict(lat=lat, lon=lon, popup=f"Marker {i+1}") for i, (lat, lon) in enumerate(zip(lats, lons)) ])

Create cluster group with GeoJSON

cluster_group = dl.MarkerClusterGroup(children=[dl.GeoJSON(data=geojson_data)])

Dash layout

app = dash.Dash(name) app.layout = html.Div([ dl.Map(center=(-37.81, 144.96), zoom=12, children=[ dl.TileLayer(), cluster_group ], style={'width': '100%', 'height': '80vh'}) ])

if name == "main": app.run(debug=True)

LarBlu0001 avatar Jul 30 '25 23:07 LarBlu0001