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