Is there a reason you're passing so many layers at a time to the base map?
Because I think that approach is enough to confuse the basemap layer with regards to which tile to use.
Every zoom in or zoom out fires an event to load the appropriate tileLayer for that zoom level, and I think
your current approach will simply cause the application to keep loading different tiles for different map types at different zoom levels.
That should be confusing enough for the map to not render properly.
Below is an approach I worked on sometime back. It's a Springboot application, which uses one map type at a time (OpenStreet Map, Mapbox, Bing Map and Google Map -> (Hybrid and Satellite)), until the user selects a particular map type to switch to.
N/B: if you are not a java developer or do not use SpringBoot, you may simply extract the html, css and js files and modify them accordingly.
You can clone and make changes to load terrain or satellite view.
Example:
If you want satellite view, you can create a new property in the DOMEndpoints Object of the data.js like this:
Then initialize a streetView layer in the init.js like this:
/**
* SATELLITE VIEW MAP TILE LAYER (GOOGLE)
* ---------------------------------------------------------------------------
*/
const GOOGLE_SATELLITE_VIEW_LAYER = L.tileLayer(DOMEndpoints.GoogleSatelliteTileLayer, {
attribution: DOMEndpoints.GoogleAttribution,
maxNativeZoom: MAX_ZOOM_VALUE,
detectRetina: true,
subdomains:['mt0','mt1','mt2','mt3']
});
Then write a function that when invoked, will change the base map to Google Satellite View:
/**
* FUNCTION TO INITIALIZE GOOGLE-SATELLITE-MAP
* -------------------------------------------
*/
const initGoogleSatelliteMap = () => {
map.removeLayer(BING_TILE_LAYER);
map.removeLayer(GOOGLE_TILE_LAYER);
map.removeLayer(OPENSTREET_TILE_LAYER);
map.removeLayer(
MAPBOX_TILE_LAYER);
GOOGLE_SATELLITE_VIEW_LAYER.addTo(map);
};
Finally add a button in the map.html that when clicked, will invoked the
initGoogleSatelliteMap() function :
$(DOMIds.mapboxButton).on(DOMEvents.click, ()=> {
initGoogleSatelliteMap();
persistMapTypeInIndexedDB(GOOGLE_SATELLITE_VIEW_LAYER );
});
That was my approach by the way....
...if it's not too much of an overkill for you.