Thanks. In DSS 9 it can be a bit challenging to get assets to work, but it can be done. Here is a small example that should work out of the box,
# Setup per-app assets folder.
import os
from dash_extensions.dataiku import bind_assets_folder
app_id = "my_app"
os.environ["ASSETS_FOLDER"] = f"assets/{app_id}"
assets_folder = os.path.join(os.getcwd(), "assets")
os.makedirs(assets_folder, exist_ok=True)
# region Normal Dash app
import dash_html_components as html
import dash_leaflet as dl
import dash_leaflet.express as dlx
from dash_extensions.enrich import DashProxy
from dash_extensions.javascript import assign
# A few countries.
countries = [dict(name="Denmark", iso2="dk", lat=56.26392, lon=9.501785),
dict(name="Sweden", iso2="se", lat=59.334591, lon=18.063240),
dict(name="Norway", iso2="no", lat=59.911491, lon=9.501785)]
# Generate geojson with a marker for each country and name as tooltip.
geojson = dlx.dicts_to_geojson([{**c, **dict(tooltip=c['name'])} for c in countries])
# Create javascript function that draws a marker with a custom icon, in this case a flag hosted by flagcdn.
draw_flag = assign("""function(feature, latlng){
const flag = L.icon({iconUrl: `https://flagcdn.com/64x48/${feature.properties.iso2}.png`, iconSize: [64, 48]});
return L.marker(latlng, {icon: flag});
}""")
# Create example app.
my_app = DashProxy()
my_app.layout = html.Div([
dl.Map(children=[
dl.TileLayer(), dl.GeoJSON(data=geojson, options=dict(pointToLayer=draw_flag), zoomToBounds=True)
], style={'width': '100%', 'height': '50vh', 'margin': "auto", "display": "block"}, id="map"),
])
# endregion
# Inject state into the app object from dataiku.
bind_assets_folder(app, app_id , assets_folder)
my_app.hijack(app)