Plotly Maps Offline

Hello,

I’m trying to use Plotly maps offline like charts, but I’m encountering difficulties.

Issue:
I’m unable to properly render maps offline using plotly-latest.min.js.

While i run map in offline mod plots showing but map not showing

unless i connect pc to internet

any help ?

hi @Monther213
:wave: Welcome to the community. What chart type are you using?

There is a post that talks about solutions to this type of challenge.

hello dear
It’s my honor to be one of your community

for my case i want to make map showing in offline PC i will provide u code that i use and it works fine with PC having internet but otherwise it’s not

Code:

import json
import plotly.graph_objects as go

Load the pre-downloaded map data from the JSON file

with open(“Z:\EXE\LOG\Python MAP\output_tiles.json”) as file:
map_data = json.load(file)

Create a Figure object

fig = go.Figure()

Add a trace for the map of Oman

fig.add_trace(go.Choroplethmapbox(
geojson=map_data,
locations=[‘Oman’], # Specify the location as ‘Oman’
z=[1], # Specify the color values for the map
colorscale=‘Viridis’,
marker_opacity=0.5,
marker_line_width=0
))

Configure the layout

fig.update_layout(
mapbox_style=“carto-positron”, # Specify the map style
mapbox_zoom=5, # Set the initial zoom level
mapbox_center={“lat”: 20.6027, “lon”: 56.0949}, # Set the center coordinates to Oman
margin={“r”: 0, “t”: 0, “l”: 0, “b”: 0}
)

Display the map

fig.show()

regards