-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapbox addLayer not working for satellite-streets style #7959
Comments
@sumitparkash thanks for using mapbox-gl-js! I think the Mapbox supporting team could better answer this question about how the APIs work. I'm not sure which styles are supported with that API. https://www.mapbox.com/contact/ You may be able to work around your issue with https://docs.mapbox.com/api/maps/#retrieve-raster-tiles-from-styles
|
Thanks for the reply. Also, I try the solution you provide but still got the error.
This is the error I got Also, i follow the link you mention Can you please suggest how to use raster tiles with addLayer Thanks |
Also going through the network panel request in chrome devtool inspect panel found that for the streets view it sends the following request https://api.mapbox.com/styles/v1/mapbox/streets-v9?access_token=YOURTOKEN In the URL replace the streets with the satellite-streets But not able to find any documentation about how this url can be used with mapbox.addLayer. |
You can use it by specifying
Replace |
I try the code you mention it did work. But the layout is a bit strange. Can you mention the change in the above code, probably i think for the value I did try to read the documenation but ot able to get what should be the value of the Thanks |
I think that api (https://docs.mapbox.com/api/maps/#retrieve-raster-tiles-from-styles) defaults to 512px tiles so you can remove |
I had try to set the Below links to jsfiddle to check the difference Below the link you referr, there is a section https://docs.mapbox.com/api/maps/#styles But i am not sure how this link can be passed with |
Also @ansis , it has been a week I contacted the mapbox support Thanks |
You should leave |
that works fine. |
Mapbox cannot retain the custom layer after you change the map style using SetStyle as discuss in previous issues:
#2267
#3979
A solution to change the map style while keeping the previous custom layer is to use the map addLayer.
Add different layer with addLayer , then show the layer accordingly by setting the layer
visibility to visible or hidden using setLayoutProperty as described below:
map.addSource("mapbox-satellite", { "type": "raster", "url": "mapbox://mapbox.satellite", "tileSize": 256 }); map.addLayer({ "type": "raster", "id": 'satellite-map', "source": "mapbox-satellite" });
Mapbox provided different styles for the map
streets
light
dark
satellite
basic
satellite-streets
Now I am trying to add those layer using map.addLayer. However, for some layer, it's not working.
it's not working for basic and satellite-streets
I have created a jsfiddle
https://jsfiddle.net/devsumitparkash/zetwapkn/
If you check the jsfiddle you will see that the addlayer not working for basic , bright, satellite-streets
I checked in the console and giving the error for these layers
GET https://api.mapbox.com/v4/mapbox.satellite-streets.json?secure&access_token=pk.eyJ1IjoiZGV2cGFya2FzaHN1bWl0IiwiYSI6ImNqc242dmNvcTAwdno0YXFuMzQ4MGlzbWkifQ.nhpUN4VR3Lvd7_gjtsIesg 404 (Not Found)
It would be great if anyone can suggest a way to have it working for the basic , bright, satellite-streets also.
The text was updated successfully, but these errors were encountered: