Skip to content

Commit fdebe93

Browse files
Update map_utils (#1870)
Update map_utils Made in [Fused Workbench](https://www.fused.io/workbench) Co-authored-by: milind@fused.io <milind@fused.io>
1 parent b2f8c9e commit fdebe93

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

community/milind/map_utils/map_utils.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
# - 5c90ffc: smooth color gradients for continuous colors (linear interpolation)
9595
# - ab686b7: add collapsible layer groups to layer panel
9696
# - ea497b4: move group border to bottom of group content
97-
FUSEDMAPS_CDN_REF_DEFAULT = "ea497b4"
97+
FUSEDMAPS_CDN_REF_DEFAULT = "2f5aab9"
9898
FUSEDMAPS_CDN_JS = f"https://cdn.jsdelivr.net/gh/milind-soni/fusedmaps@{FUSEDMAPS_CDN_REF_DEFAULT}/dist/fusedmaps.umd.js"
9999
FUSEDMAPS_CDN_CSS = f"https://cdn.jsdelivr.net/gh/milind-soni/fusedmaps@{FUSEDMAPS_CDN_REF_DEFAULT}/dist/fusedmaps.css"
100100
FUSEDMAPS_SCHEMA_URL = f"https://cdn.jsdelivr.net/gh/milind-soni/fusedmaps@{FUSEDMAPS_CDN_REF_DEFAULT}/fusedmaps.schema.json"
@@ -137,9 +137,6 @@ def _fusedmaps_cdn_urls(ref: typing.Optional[str] = None) -> tuple[str, str, str
137137
<div id="map"></div>
138138
{custom_body}
139139
<script>
140-
// User-provided pre_init script (runs BEFORE FusedMaps init - good for BroadcastChannel listeners)
141-
{pre_init}
142-
143140
// Initialize even if cartocolor fails to load (network/csp issues).
144141
// If cartocolor loads later, palettes will start working for subsequent style updates.
145142
function waitForCartocolor(callback, tries) {{
@@ -256,9 +253,7 @@ def deckgl_layers(
256253
custom_head: str = "", # HTML to inject in <head> (scripts, stylesheets)
257254
custom_css: str = "", # CSS rules to inject in <style>
258255
custom_body: str = "", # HTML to inject in <body> (custom UI elements)
259-
pre_init: str = "", # JavaScript to run BEFORE FusedMaps.init() - good for BroadcastChannel listeners
260256
on_init: str = "", # JavaScript to run after FusedMaps.init() - has access to `map` and `instance`
261-
return_raw_html: bool = False, # Return raw HTML string instead of html_to_obj (enables BroadcastChannel messaging)
262257
):
263258
"""
264259
Render mixed hex and vector layers on a single interactive map.
@@ -287,12 +282,9 @@ def deckgl_layers(
287282
custom_head: HTML to inject in <head> (e.g., external scripts, stylesheets).
288283
custom_css: CSS rules to inject (without <style> tags).
289284
custom_body: HTML to inject in <body> (e.g., custom UI containers).
290-
pre_init: JavaScript code to run BEFORE FusedMaps.init(). Use this for:
291-
- BroadcastChannel listeners (must be set up before async init)
292-
- postMessage listeners for JSON UI integration
293285
on_init: JavaScript code to run after FusedMaps.init(). Has access to:
294-
- `__fm_instance`: The FusedMaps instance (with .getLayers, .updateLayer, etc.)
295-
- `__fm_map`: The Mapbox GL map instance
286+
- `map`: The Mapbox GL map instance
287+
- `instance`: The FusedMaps instance (with .store, .addLayer, etc.)
296288
- `config`: The FusedMaps config object
297289
298290
Returns:
@@ -635,12 +627,12 @@ def deckgl_layers(
635627
custom_head=custom_head or "",
636628
custom_css=custom_css or "",
637629
custom_body=custom_body or "",
638-
pre_init=pre_init or "",
639630
on_init=on_init or "",
640631
)
641632

642-
# Return raw HTML string (enables BroadcastChannel messaging for JSON UI components)
643-
return html
633+
# Return as HTML object
634+
common = fused.load("https://github.com/fusedio/udfs/tree/bb3aa1b/public/common/")
635+
return common.html_to_obj(html)
644636

645637

646638
def deckgl_hex(

0 commit comments

Comments
 (0)