简体   繁体   中英

Mapbox showing blank map

Hello I have an issue with my mapbox. When I ran the code, it was successful, but the map itself didn't show, while the pin point appeared (I attach the screenshot at the link below). can anyone help me? my code is below. Did i do anything wrong? my api is valid, I have checked it. Furthermore, I also have checked at the similar problem in internet, but none of them work for my issue.

error

在此处输入图像描述

from plotly import express as px
import requests
import plotly
mapbox_token = requests.get('https://api.mapbox.com/?access_token=myaccesstoken').text
px.set_mapbox_access_token(mapbox_token)
plot=[1.44255, 103.79580]
plot=pd.DataFrame(plot).T
plot.columns=['lat','long']
fig = px.scatter_mapbox(plot, lat="lat", lon="long", size_max=20, height=760, zoom=10, 
                    title='test', range_color=(0,700))
fig.update_layout(mapbox_style="dark", mapbox_accesstoken=mapbox_token)
fig.show()

I try the code in spyder, it doesn't work. But it works in jupyter. And I think that maybe 'plotly' does not work in jupyter.

from plotly import express as px
import pandas as pd
import plotly
mapbox_token = 'your token copied from mapbox'
px.set_mapbox_access_token(mapbox_token)
plot=[1.44255, 103.79580]
plot=pd.DataFrame(plot).T
plot.columns=['lat','long']
fig = px.scatter_mapbox(plot, lat="lat", lon="long", size_max=20, height=760, zoom=10, 
                title='test', range_color=(0,700))
fig.update_layout(mapbox_style="dark", mapbox_accesstoken=mapbox_token)
fig.show()

Jow: I ran it in Google Colab and it showed a perfect dark Mapbox map with the blue dot located in the vicinities of Woodlands Dr 40, Woodlands, Singapur. So your code works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM