我正在尝试使用 dash_leaflet 中的 GeoJSON 显示一些地图,它工作正常,但出于性能原因,我必须使用 javascript 来更改点的显示方式。在本地它工作正常,但是一旦我将代码上传到 pythonanywhere,就会显示地图,但不会显示点。如果我注释参数选项(在下面的代码中),则会显示点,但不是我想要的方式,这会导致性能问题...
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"},
)
我在pythonanywhere的论坛上打开了一个主题(https://www.pythonanywhere.com/forums/topic/32111/#id_post_107799),并按照工作人员的建议查看了我的浏览器开发工具中的问题。我发现了这两个问题:
Error: No match for [dashExtensions.default.function0] in the global window object.
r index.js:33
r index.js:18
o index.js:53
value React
Ie [email protected]_7_0m1670302186.14.0.min.js:104
rh [email protected]_7_0m1670302186.14.0.min.js:103
zj [email protected]_7_0m1670302186.14.0.min.js:228
Th [email protected]_7_0m1670302186.14.0.min.js:152
tj [email protected]_7_0m1670302186.14.0.min.js:152
Te [email protected]_7_0m1670302186.14.0.min.js:146
Pg [email protected]_7_0m1670302186.14.0.min.js:61
unstable_runWithPriority [email protected]_7_0m1670302186.14.0.min.js:25
Da [email protected]_7_0m1670302186.14.0.min.js:60
Pg [email protected]_7_0m1670302186.14.0.min.js:61
ha [email protected]_7_0m1670302186.14.0.min.js:60
Dj [email protected]_7_0m1670302186.14.0.min.js:163
unstable_runWithPriority [email protected]_7_0m1670302186.14.0.min.js:25
Da [email protected]_7_0m1670302186.14.0.min.js:60
xb [email protected]_7_0m1670302186.14.0.min.js:162
Bj [email protected]_7_0m1670302186.14.0.min.js:162
U [email protected]_7_0m1670302186.14.0.min.js:16
onmessage [email protected]_7_0m1670302186.14.0.min.js:24
EventHandlerNonNull* [email protected]_7_0m1670302186.14.0.min.js:24
<anonymous> [email protected]_7_0m1670302186.14.0.min.js:9
<anonymous> [email protected]_7_0m1670302186.14.0.min.js:9
...
和
Error: No match for [dashExtensions.default.function0] in the global window object.
r index.js:33
r index.js:18
o index.js:53
value React
Ie [email protected]_7_0m1670302186.14.0.min.js:104
rh [email protected]_7_0m1670302186.14.0.min.js:103
zj [email protected]_7_0m1670302186.14.0.min.js:228
Th [email protected]_7_0m1670302186.14.0.min.js:152
tj [email protected]_7_0m1670302186.14.0.min.js:152
Te [email protected]_7_0m1670302186.14.0.min.js:146
Pg [email protected]_7_0m1670302186.14.0.min.js:61
unstable_runWithPriority [email protected]_7_0m1670302186.14.0.min.js:25
Da [email protected]_7_0m1670302186.14.0.min.js:60
Pg [email protected]_7_0m1670302186.14.0.min.js:61
ha [email protected]_7_0m1670302186.14.0.min.js:60
Dj [email protected]_7_0m1670302186.14.0.min.js:163
unstable_runWithPriority [email protected]_7_0m1670302186.14.0.min.js:25
Da [email protected]_7_0m1670302186.14.0.min.js:60
xb [email protected]_7_0m1670302186.14.0.min.js:162
Bj [email protected]_7_0m1670302186.14.0.min.js:162
U [email protected]_7_0m1670302186.14.0.min.js:16
onmessage [email protected]_7_0m1670302186.14.0.min.js:24
EventHandlerNonNull* [email protected]_7_0m1670302186.14.0.min.js:24
<anonymous> [email protected]_7_0m1670302186.14.0.min.js:9
<anonymous> [email protected]_7_0m1670302186.14.0.min.js:9
...
我也有同样的问题,这个问题可能是Python环境造成的。你应该使用Python 3.10版本