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

@Monther213 were you ever able to get this working? i have the same issue trying to produce a plot in notebook…ive transferred the JSON file to the disconnect machine as well as installed the plotly_geo .whl but neither work…

as noted above theres a post that shows some solutions but they appear to be directed towards folks using Dash…

i’m rather new to plotly so maybe those solutions will work for notebook users, but i cant seem to figure out how