Non-API / no Internet detailed (enough) map

Hello Plotly community! I’m looking for a way to deploy an app with no outgoing calls to the internet. The app will be hosted in a closed environment (asking for a friend). I see a lot of mapbox examples and they’re pretty easy to deploy, but need mapbox api. Is dash_leaflet a good solution for something like that? Thank you!

Yes, dash_leaflet is an excellent solution for deploying mapping applications in a closed environment with no outgoing calls to the internet. Dash Leaflet is a Dash component library for creating interactive maps based on the Leaflet JavaScript library. One of the key benefits of using Dash Leaflet for your application is its ability to use locally hosted maps or map tiles, thus eliminating the need for internet access or reliance on external APIs like Mapbox.

Why Choose Dash Leaflet for Offline Maps:

  1. Local Tile Servers: You can serve map tiles from a local tile server or include a set of tiles directly within your application if the geographic area of interest is limited. This approach removes the dependency on external map services.
  2. GeoJSON and TopoJSON Support: Dash Leaflet supports GeoJSON and TopoJSON formats, allowing you to render complex geographic data and shapes directly onto your maps without requiring an internet connection to fetch this data.
  3. Interactive Features: Despite being offline, you can still build interactive maps with features like markers, popups, and even dynamic updates based on user interaction, all of which are essential for a rich user experience.
  4. Integration with Dash: Being a part of the Dash ecosystem, Dash Leaflet seamlessly integrates with other Dash components, enabling you to build comprehensive dashboards that include interactive maps alongside other visualizations and UI elements.

Steps to Use Dash Leaflet in a Closed Environment:

  1. Install Dash Leaflet: Ensure that Dash and Dash Leaflet are installed in your environment. Dash Leaflet can be installed via pip:
pip install dash-leaflet
  1. Prepare Local Map Tiles: If you’re not accessing map tiles from an external source, you’ll need to prepare your map tiles and host them within your environment. Tools like TileMill or QGIS can generate tiles from geographic data.
  2. Configure Dash App to Use Local Tiles: When creating your map in Dash Leaflet, specify the URL for your locally hosted tiles. Here’s a simple example:
import dash
import dash_leaflet as dl
from dash import html

app = dash.Dash(__name__)

app.layout = html.Div([
    dl.Map([dl.TileLayer(url="path/to/your/local/tiles/{z}/{x}/{y}.png")],
           style={'width': '1000px', 'height': '500px'}, center=[40.7128, -74.0060], zoom=10)
])

if __name__ == '__main__':
    app.run_server(debug=True)

  1. Replace "path/to/your/local/tiles/{z}/{x}/{y}.png" with the actual path to your tiles.
  2. Deploy Your App: With your map tiles hosted locally and your app configured to use these local resources, you can deploy your app within your closed environment without needing any internet access.
1 Like

Thank you @PipInstallPython!