原生的按钮
自定义一个,仿生按钮
<div id="cesiumContainer">
<button class="btn" ref="newBtn" @click="buttonClick()"></button>
</div>
const initViewer = () => {
viewer.value = new Cesium.Viewer("cesiumContainer", {
animation: true,
baseLayerPicker: true,
fullscreenButton: true,
vrButton: false,
geocoder: false,
homeButton: true,
sceneModePicker: true,
selectionIndicator: true,
timeline: true,
navigationHelpButton: true,
infoBox: false,
});
viewer.value.cesiumWidget.creditContainer.style.display = "none";
viewer.value.scene.globe.depthTestAgainstTerrain = true;
const imageryProvider = new Cesium.UrlTemplateImageryProvider({
url: "cesium-api/map/getMap/{x}/{y}/{z}.png",
credit: "mapname",
tilingScheme: new Cesium.GeographicTilingScheme({
ellipsoid: Cesium.Ellipsoid.WGS84,
}),
maximumLevel: 18,
});
viewer.value.scene.imageryLayers.addImageryProvider(imageryProvider);
viewer.value.navigationHelpButton.container.appendChild(newBtn.value);
};
<style scoped>
#cesiumContainer {
width: 100%;
height: 671px;
}
.btn {
border-radius: 5px;
height: 32px;
width: 32px;
position: absolute;
left: -34px;
background: #303336 url(../../assets//index/搜索.png);
border: 1px solid #303336;
background-size: cover;
z-index: 6;
cursor: pointer;
}
.btn:hover {
color: #fff;
fill: #fff;
background-color: #4488bb;
background-size: cover;
border-color: #aef;
box-shadow: 0 0 8px #fff;
}
</style>