设置Mapbox地图,设置homebutton

版本1.43

设置Mapbox地图

var viewer = new Cesium.Viewer('cesiumContainer',{
    imageryProvider : new Cesium.MapboxImageryProvider({
        mapId : 'mapbox.satellite'
    }),    
});

设置homebutton位置

var initialPosition = new Cesium.Cartesian3.fromDegrees(114.044,22.59,2000);
var initialOrientation = new Cesium.HeadingPitchRoll.fromDegrees(0, -40, 0);
var homeCameraView = {
    destination : initialPosition,
    orientation : {
        heading : initialOrientation.heading,
        pitch : initialOrientation.pitch,
        roll : initialOrientation.roll
    }
};

// Set the initial view
viewer.scene.camera.setView(homeCameraView);

// Add some camera flight animation options
homeCameraView.duration = 2.0;
homeCameraView.maximumHeight = 2000;
homeCameraView.pitchAdjustHeight = 2000;
homeCameraView.endTransform = Cesium.Matrix4.IDENTITY;
// Override the default home button
viewer.homeButton.viewModel.command.beforeExecute.addEventListener(function (e) {
    e.cancel = true;
    viewer.scene.camera.flyTo(homeCameraView);
});

效果如下




你可能感兴趣的:(Cesium)