plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Mapbox Standard Map Style Not Showing

Open Sang-Buster opened this issue 1 year ago • 9 comments

Hi,

Mapbox recently came out with an absolutely stunning new map style named standard see demo, which requires GL JS 3, I was trying to import the script and stylesheet into my dash app externally as follows,

mapbox_scripts = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js']
mapbox_stylesheets = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css']
app = dash.Dash(__name__, external_stylesheets=mapbox_stylesheets, external_scripts=mapbox_scripts)

Which indeed is imported through browser inspector. However, it did not show the base map, it's just a blank background with some of my data point markers I manually put in. And I have tried this procedure using in just a html file, which does load the map properly, this may be a feature request or a bug report. I have tried all other mapbox style with different versions, which they all works and looks great, but it would be wonderfult if this stunning 3d map style is embded into plotly.

Thanks!

Sang-Buster avatar Dec 17 '23 03:12 Sang-Buster

hi @Sang-Buster Are you able to share the full dash app with us, or at least a minimal reproducible example? Are you using your own mapbox token for this?

Coding-with-Adam avatar Dec 18 '23 19:12 Coding-with-Adam

hi @Sang-Buster Are you able to share the full dash app with us, or at least a minimal reproducible example? Are you using your own mapbox token for this?

Hi, yes I'm using my own mapbox token, and here is the dash app source code repo. Please run the app.py from the root directory of the project file, the token needs to be put inside /src/components/map_component.py file and I have the steeet style as of now, I did try using my own custom style url with the standard style it does not work either.

Sang-Buster avatar Dec 18 '23 19:12 Sang-Buster

Thank you, @Sang-Buster . I'm getting an sqlite3 error when I try to run your app.

sqlite3.OperationalError: unable to open database file

You know how I can fix that?

Coding-with-Adam avatar Dec 18 '23 19:12 Coding-with-Adam

Thank you, @Sang-Buster . I'm getting an sqlite3 error when I try to run your app.

sqlite3.OperationalError: unable to open database file

You know how I can fix that?

Hi, I'm not sure what is causing this, but you can try to rerun the /src/data/agent_fake_data.py file, to rewrite some fake data into the .DB file and terminate the fake data generation whenever you want to. Let me know if the problem presists. Thanks again for the quick response and help!

Sang-Buster avatar Dec 18 '23 19:12 Sang-Buster

Hi,

Mapbox recently came out with an absolutely stunning new map style named standard see demo, which requires GL JS 3, I was trying to import the script and stylesheet into my dash app externally as follows,

mapbox_scripts = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js']
mapbox_stylesheets = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css']
app = dash.Dash(__name__, external_stylesheets=mapbox_stylesheets, external_scripts=mapbox_scripts)

Which indeed is imported through browser inspector. However, it did not show the base map, it's just a blank background with some of my data point markers I manually put in. And I have tried this procedure using in just a html file, which does load the map properly, this may be a feature request or a bug report. I have tried all other mapbox style with different versions, which they all works and looks great, but it would be wonderfult if this stunning 3d map style is embded into plotly.

Thanks!

Oh I just thought this culd be the file directory naming issue, I'm using Windows so it uses / maybe in Linux or max uses different folder separate symbols, that said, you will need to change file directory naming in the read_data function in every component.py script in the components folder. Or this can be solved if you run the app.py from root directory, do not cd into src folder.

Sang-Buster avatar Dec 18 '23 19:12 Sang-Buster

Wonderful, now I got it to run. This is with mapbox://styles/mapbox/streets-v12.

This also has the script and stylesheet you importe:

mapbox_scripts = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js']
mapbox_stylesheets = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css']

image

Did you not get the same result?

Coding-with-Adam avatar Dec 18 '23 19:12 Coding-with-Adam

Wonderful, now I got it to run. This is with mapbox://styles/mapbox/streets-v12.

This also has the script and stylesheet you importe:

mapbox_scripts = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js']
mapbox_stylesheets = ['https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css']

image

Did you not get the same result?

Right the street map style does not rely on the v3 script and stylesheet, so you can delete them and the map will still show for all other maps type except for standard style. So I was trying inject them and it does get injected but it was still not showing. And I know my mapbox token is fine and using my custom standard style url or using mapbox://styles/mapbox/standard works as I have tested it out in a html file.

Sang-Buster avatar Dec 18 '23 20:12 Sang-Buster

@LiamConnors would it be possible to add the ability to assign the new standard map style to the mapbox style attribute?

Coding-with-Adam avatar Dec 18 '23 21:12 Coding-with-Adam

Sorry, in addition is it possible for the scattermapbox to be 3d if we're using standard style, similar to scatter_3d function? It seems to me scattermapbox only supports 2d plot with lon or lat, a third dimentsion of elevation/elev for pint markers will make it look great. Thanks for the considerations .

Sang-Buster avatar Dec 19 '23 19:12 Sang-Buster

@archmoj does this connect with your recent work at all?

gvwilson avatar Aug 13 '24 13:08 gvwilson