-
Notifications
You must be signed in to change notification settings - Fork 26
fix: implement dash-leaflet #235, address #272 #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import dash_bootstrap_components as dbc | ||
| from dash_extensions.enrich import DashProxy, ServersideOutputTransform | ||
| from flask import send_file | ||
|
|
||
| app = DashProxy( | ||
| __name__, | ||
|
|
@@ -10,6 +11,22 @@ | |
| ) | ||
| TIMEOUT = 600 | ||
|
|
||
|
|
||
| @app.server.route("/geojson/locations") | ||
| def serve_locations_geojson(): | ||
| return ( | ||
| send_file( | ||
| "assets/data/locations.geojson.gz", | ||
| mimetype="application/json", | ||
| as_attachment=False, | ||
| download_name="locations.geojson", | ||
| conditional=True, | ||
| ), | ||
| 200, | ||
| {"Content-Encoding": "gzip", "Cache-Control": "no-cache"}, | ||
| ) | ||
|
Comment on lines
+15
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use cache-friendly headers for the GeoJSON endpoint. Line 26 sets 💡 Suggested change `@app.server.route`("/geojson/locations")
def serve_locations_geojson():
return (
send_file(
"assets/data/locations.geojson.gz",
mimetype="application/json",
as_attachment=False,
download_name="locations.geojson",
conditional=True,
),
200,
- {"Content-Encoding": "gzip", "Cache-Control": "no-cache"},
+ {
+ "Content-Encoding": "gzip",
+ "Cache-Control": "public, max-age=31536000, immutable",
+ },
)🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| app.index_string = """<!DOCTYPE html> | ||
| <html lang="en-US"> | ||
| <head> | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| .marker-cluster-small { | ||
| background-color: rgba(248, 249, 250, 0.6); | ||
| } | ||
| .marker-cluster-medium { | ||
| background-color: rgba(172, 227, 251, 0.6); | ||
| } | ||
| .marker-cluster-large { | ||
| background-color: rgba(35, 139, 230, 0.6); | ||
| } | ||
| .marker-cluster-small div { | ||
| background-color: rgba(240, 247, 249, 0.8); | ||
| } | ||
| .marker-cluster-medium div { | ||
| background-color: rgba(172, 227, 251, 0.8); | ||
| } | ||
| .marker-cluster-large div { | ||
| background-color: rgba(35, 139, 230, 0.8); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| window.dashExtensions = Object.assign({}, window.dashExtensions, { | ||
| default: { | ||
| function0: function (feature, latlng, ctx) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. function0 is not used and can be removed. |
||
| const p = feature.properties; | ||
| const color = p.source === "ep" ? "#3a0ca3" : "#4895ef"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking that the source is equal to "ep" which is a string, it is quite dangerous because we may miss this in the future, can we find a more elegant solution? for example to define a class with the two different sources. |
||
| const marker = L.circleMarker(latlng, { | ||
| radius: 5, | ||
| color: color, | ||
| fillColor: color, | ||
| fillOpacity: 0.8, | ||
| weight: 1, | ||
| }); | ||
|
|
||
| let html = | ||
| "<b>" + | ||
| (p.title || "") + | ||
| "</b><br/>" + | ||
| "Lat: " + | ||
| latlng.lat.toFixed(2) + | ||
| ", Lon: " + | ||
| latlng.lng.toFixed(2) + | ||
| "<br/>"; | ||
| if (p.source === "ob") { | ||
| html += | ||
| "Period: " + | ||
| (p.period || "N/A") + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PyCharm is complaining that this may not be defined, the same for the other attributes of p. Can we give a more meaningful name to P? Perhaps we can call it "Properties of XXX" |
||
| "<br/>" + | ||
| "Elevation: " + | ||
| (p.elev || "N/A") + | ||
| " m<br/>" + | ||
| "Time zone: GMT" + | ||
| (p.tz || "N/A") + | ||
| "<br/>" + | ||
| "99% Heating DB: " + | ||
| (p.heat99 || "N/A") + | ||
| "<br/>" + | ||
| "1% Cooling DB: " + | ||
| (p.cool1 || "N/A") + | ||
| "<br/>" + | ||
| "Source: Climate.OneBuilding.Org"; | ||
| } else { | ||
| html += "Source: EnergyPlus"; | ||
| } | ||
| marker.bindTooltip(html, { | ||
| sticky: true, | ||
| opacity: 0.9, | ||
| }); | ||
| return marker; | ||
| }, | ||
| }, | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
What is the latest stable dash-leaflet release, and which versions are compatible with Dash 3.x?💡 Result:
Latest stable dash-leaflet release: 1.1.3 [1][2]. Dash 3.x compatibility: - dash-leaflet 1.1.3 declares a dependency constraint of dash >=3.0.0, so it is compatible with Dash 3.x releases [1][2]. - The dash-leaflet project also documents that versions 1.1.1+ were released as “Dash 3 compatible” and notes a specific incompatibility issue related to Dash 3 / React 18.3 that was addressed via updates [3]. Practical takeaways: - Use dash-leaflet==1.1.3 with Dash 3.x (>=3.0.0) [1][2].
Citations:
🏁 Script executed:
Repository: CenterForTheBuiltEnvironment/clima
Length of output: 188
🌐 Web query:
dash-leaflet latest version PyPI and compatibility with dash 3.x💡 Result:
Latest dash-leaflet version on PyPI (as of 2026-05-26): 1.1.3 [1]. Compatibility with Dash 3.x: - dash-leaflet 1.1.3 declares a dependency on dash >= 3.0.0, so it is intended to work with Dash 3.x (and will not allow Dash 2.x) [1][2]. - The dash-leaflet 1.1.3 metadata also indicates Python >= 3.11 [1][2]. - Dash 3.0 is documented by Plotly as removing/altering some older component stubs and includes breaking changes; if your app uses any libraries/components that Dash 3 requires to be updated, you may need to update those libraries too [3]. Recommended install (to match the intended constraints): - pip install "dash>=3" "dash-leaflet==1.1.3" [1][2].
Citations:
🏁 Script executed:
Repository: CenterForTheBuiltEnvironment/clima
Length of output: 1897
🏁 Script executed:
Repository: CenterForTheBuiltEnvironment/clima
Length of output: 155
🏁 Script executed:
Repository: CenterForTheBuiltEnvironment/clima
Length of output: 2832
🌐 Web query:
dash-leaflet 1.0.15 dependency on dash (Dash >=?) PyPI💡 Result:
dash-leaflet 1.0.15 declares a dependency on Dash with the constraint dash >=2.13.0 on PyPI. [1] So the answer to “Dash >=?” is: Dash >= 2.13.0. [1]
Citations:
🌐 Web query:
dash-leaflet 1.0.15 Dash 3 compatibility💡 Result:
Dash-leaflet 1.0.15 is not considered “Dash 3 compatible” on its own. Instead, Dash 3 compatibility was implemented starting from dash-leaflet 1.1.0 (and related 1.1.x releases), while 1.0.15 only declares compatibility with Dash >=2.13.0. Evidence: - The PyPI page for dash-leaflet 1.0.15 shows a dependency constraint of dash >=2.13.0 (no Dash 3-specific minimum is stated for 1.0.15). [1] - The project changelog/compare history between 1.0.15 and 1.1.0 explicitly notes “Working in Dash 3 compatibility” and “Update dependency to Dash 3.0.0” as part of the 1.1.0 change. [2] - There is a GitHub issue reporting incompatibility when using dash=3 with dash-leaflet (and discussing fixes that were released in later 1.1.x versions), indicating that older 1.0.x builds can be problematic with Dash 3. [3] Practical takeaway: - If you need Dash 3 compatibility, use dash-leaflet 1.1.0 or later (for example, 1.1.3). [2][4] Install guidance: - pip install dash>=3 dash-leaflet>=1.1.0
Citations:
Pin
dash-leafletand align it with Dash 3.2.Pipfileusesdash-leaflet = "*"(drift risk);Pipfile.lockcurrently pinsdash-leaflet==1.0.15.dash-leaflet==1.0.15is not the Dash 3–compatible line (Dash 3 compatibility started indash-leaflet1.1.0+). Upgrade to a Dash 3–compatible version (e.g.,dash-leaflet==1.1.3) and regeneratePipfile.lock.🤖 Prompt for AI Agents