我希望在缩放等级超过一定程度时隐藏地图的标签。
对于这个示例,我想在缩放级别达到5后隐藏所有与
collection1
相关的标签:
https://codepen.io/ollazarev/pen/XBWEEq
let viewer = new Cesium.Viewer('cesiumContainer', {
animation: false,
baseLayerPicker: false,
fullscreenButton: false,
geocoder: false,
homeButton: false,
infoBox: false,
sceneModePicker: false,
timeline: false,
navigationHelpButton: false,
navigationInstructionsInitiallyVisible: false,
});
let collection1 = new Cesium.LabelCollection();
collection1.add({
position: Cesium.Cartesian3.fromDegrees(-101.678, 57.7833),
text: 'Canada',
});
collection1.add({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
text: 'Philadelphia',
});
viewer.scene.primitives.add(collection1);
let collection2 = new Cesium.LabelCollection();
collection2.add({
position: Cesium.Cartesian3.fromDegrees(-74.0059728, 40.7127753),
text: 'New York',
});
collection2.add({
position : Cesium.Cartesian3.fromDegrees(-79.38318429999998, 43.653226),
text: 'Toronto',
});
viewer.scene.primitives.add(collection2);