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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -