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
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