for example I have this setup for a fema map i’ve been working on:
dl.Map(
children=[
dl.TileLayer(id="base-tile-layer"),
*[
dl.GeoJSON(
data=geojson_data,
id=f"{state}-counties-layer",
hideout=dict(selected=[]),
style=style_handler
) for state, geojson_data in state_geojson_data.items()
],
*[
dl.LayerGroup(id=f"map-markers-{incident_type.lower().replace(' ', '-')}",
children=[])
for incident_type in DEFAULT_INCIDENT_TYPES if incident_type != 'All'
]
],
id='disaster-map',
style={'width': '100%', 'height': '80vh', 'zIndex': 0},
center=[31.0686, -99.9018],
zoom=6,
)
I was running into trouble trying to change the tooltips based on the selection of fema declaration, so I just created a dl.LayerGroup for each fema event and hid/show which dl.LayerGroup instead of trying to use the same dl.LayerGroup with re-rendering the data. Preformed much better for my use case, not specific to matching with the Polyline but it is something worth considering in trying to figure out a solution
What I ended up just using the map ‘bounds’ state and calculating the distance spanned by the map, and then clustering or not clustering based on that.