javascript - base map selector does not work -
i changing default basemap mapbox.streets in code. not update baselayer baselayerpicker widget anymore.
var viewer = new cesium.viewer('cesiumcontainer',{ animation : false, homebutton : false, baselayerpicker : true, infobox : true, scenemodepicker : true, timeline : false, navigationinstructionsinitiallyvisible : false, navigationhelpbutton : false, contextoptions: { webgl:{preservedrawingbuffer:true} }, selectionindicator : false, }); var layers = viewer.imagerylayers; var baselayer = layers.get(0); layers.remove(baselayer); layers.addimageryprovider(new cesium.mapboximageryprovider({ url : 'https://api.mapbox.com/v4/', mapid: 'mapbox.streets', }));
am missing anything? appreciated.
in code posted, you're swapping out imagery layer after viewer (and hence baselayerpicker) have been constructed. need make sure baselayerpicker constructed correct options front, pre-select intended base layer. code looks this:
var imageryproviders = cesium.createdefaultimageryproviderviewmodels(); var selectedimageryproviderindex = 4; // mapbox street 5th in list. var viewer = new cesium.viewer('cesiumcontainer', { imageryproviderviewmodels: imageryproviders, selectedimageryproviderviewmodel: imageryproviders[selectedimageryproviderindex] });
when run this, you'll note baselayerpicker starts correct item selected, , still offers options swap out other base layers.
Comments
Post a Comment