Hi I have been developing with Dash and dash_leaflet for a few time. I have 3 datasets in 3 different geojson object.
The geojson are structured as follows: list of Point, list of LineString, list of Polygon.
I want to be able to click on the polyline that could be inside on of the Polygons.
I tried to use the object Pane, passing the zIndex as style property. But it doesn’t seem to work.
I also have to add that I have a callback that selects the Polygon when is clicked.
Here’s the map definition:
crea la mappa
self.map = dl.Map(id='mapLayout',
children=[
dl.LayersControl(
[dl.BaseLayer(dl.TileLayer(),name="normal-map",checked=True),dl.BaseLayer(self.wms_layer,name="satellite-map")]+
[
dl.Pane([dl.Overlay(dl.GeoJSON(id="id-geojson-nodes", data=self.geojson_nodes,zoomToBounds=True,hideout=dict(showTooltip=False,isPermanent=True),pointToLayer=self.draw_nodes,onEachFeature=self.show_labels),name="nodes")],style={'zIndex':1000},name="paneNodes"),
dl.Pane([dl.Overlay(dl.GeoJSON(id='id-geojson-links', data=self.geojson_links,zoomToBounds=True,hideout=dict(showTooltip=False,isPermanent=True),onEachFeature=self.show_labels),name="links")],style={'zIndex':1100},name="paneLinks"),
dl.Pane([dl.Overlay(dl.GeoJSON(id="id-geojson-zones", data=self.zones, zoomToBounds=True,hideout=dict(selected=[],showTooltip=False,isPermanent=True), style=self.styleZones,onEachFeature=self.show_labels),name="zones")],style={'zIndex':900},name="paneZones")
],id="layer-control",baseLayer="normal-map",autoZIndex=True)],
style={"width": "1800", "height": "800px"},
attributionControl=False)
here is the HighlightZones callback:
self.app.callback(
Output(component_id=“id-geojson-zones”,component_property= “hideout”),
Input(“id-geojson-zones”, “n_clicks”),
State(“id-geojson-zones”, “clickData”),
State(“id-geojson-zones”, “hideout”),
prevent_initial_call=True
)(self.HighlightZone)
def HighlightZone(self,_, feature, hideout):
selected = hideout[“selected”]
name = feature[“properties”][“name”]
if name in selected:
selected.remove(name)
else:
selected.append(name)
return hideout
Here is an image:
I manage to click the point, but if i try to click the line it doesnt work, instead the polygon gets selected.
I’m sorry if I have missed something and thanks to anyone who will try to help.
I m using dash_leaflet =1.0.3