Hi,
I'm trying to display some maps using GeoJSON
from dash_leaflet
, and it works fine, but for performance reasons I have to use javascript to change the way the points are displayed. Locally it works fine, but as soon as I upload my code to pythonanywhere, the map is displayed but not the points. If I comment the argument options
(in the code below), the points are displayed, but not the way I wanted, which causes the performance issue...
import dash_leaflet as dl
from dash_extensions.javascript import assign
# Geojson rendering logic, must be JavaScript
# as it is executed in clientside.
point_to_layer = assign(
"""function(feature, latlong, context){
const {circleOptions} = context.props.hideout;
return L.circleMarker(latlong, circleOptions);
}"""
)
main_map = dl.Map(
children=[
dl.LayersControl(
children=[
dl.BaseLayer(
dl.TileLayer(),
name="Background",
checked=True,
)
]
+ [
dl.Overlay(
dl.GeoJSON(
id="dives_data",
format="geobuf",
zoomToBounds=True,
# comment options make it works...
options=dict(
pointToLayer=point_to_layer
),
hideout=dict(
circleOptions=dict(fillOpacity=1,
stroke=False,
radius=5)
),
),
checked=True,
id="overlay_dive_map",
name="Data",
)
],
id="layer_data",
),
],
center=(37, -140),
zoom=5,
style={"width": "100%", "height": "87vh", "margin": "auto"},
)