图层组得显隐控制
- 方式一
map.addLayer(图层组名称)
map.removeLayer(图层组名称)
图层组在remove得时候并没有彻底得清楚,仍然存在,所以在removeLayer后可以继续add Layer,以达到显隐得控制
- 方式二
clearFeatureGroup() {
let that = this
if (that.routeFeatureGroup) {
that.routeFeatureGroup.eachLayer(item=>{
item.eachLayer(idx =>{
idx.setOpacity(0)
})
})
}
}
判断地图上是否有图层
map.hasLayer(machineGroup)
创建图标
var customIcon = L.Icon.extend({
options: {
iconSize: [32, 40],
iconAnchor: [16, 40],
popupAnchor: [0, -20]
}
});
var macIcon = new customIcon({iconUrl: '../images/machine.png'});
var macIcon_red = new customIcon({iconUrl: '../images/machine-red.png'});
根据地图缩放级别 控制图层显隐
map.on('zoomend', function (e) {
var zoom = map.getZoom();
$.each(polygonArr,function (idx,item) {
if(zoom < item.options.zoom){
map.removeLayer(item)
}else{
map.addLayer(item)
}
});
});
开启地下模式
that.scene.undergroundMode = true //设置开启地下场景
that.scene.screenSpaceCameraController.minimumZoomDistance = -1000 //设置相机最小缩放距离,距离地表-1000米
设置相机角度
//设置相机位置、视角,便于观察场景
that.scene.camera.setView({
destination: new Cesium.Cartesian3.fromDegrees(
that.cameraObj.x,
that.cameraObj.y,
that.cameraObj.z
),
orientation: {
heading: Cesium.Math.toRadians(that.cameraObj.heading),
pitch: Cesium.Math.toRadians(that.cameraObj.pitch - 90),
roll: that.cameraObj.roll,
},
})
三维模型得显隐
let name = "bchanggui02j@4biao1015"
that.scene.layers._layers._hash[item]._visible = true
飞行路径
addFly() {
let that = this
that.hideAssetLayer()
that.flyscene.globe.depthTestAgainstTerrain = true
var camera = that.flyscene.camera
camera.setView({
destination: new Cesium.Cartesian3.fromDegrees(
that.cameraObj.x,
that.cameraObj.y,
that.cameraObj.z
),
orientation: {
heading: Cesium.Math.toRadians(that.cameraObj.heading),
pitch: Cesium.Math.toRadians(that.cameraObj.pitch - 90),
roll: that.cameraObj.roll,
},
})
var routes = new Cesium.RouteCollection(that.viewer.entities)
var fpfUrl = '/fly/bim全路段飞行路径.fpf'
routes.fromFile(fpfUrl)
var flyManager = new Cesium.FlyManager({
scene: that.flyscene,
routes: routes,
})
flyManager.playRate = 0.3
flyManager.readyPromise.then(function () {
var currentRoute = flyManager.currentRoute
currentRoute.isLineVisible = false
currentRoute.isStopVisible = false
document.getElementById('play').onclick = function () {
alert('开始飞行')
flyManager && flyManager.play()
}
document.getElementById('pause').onclick = function () {
alert('暂停飞行')
flyManager && flyManager.pause()
}
document.getElementById('stop').onclick = function () {
alert('停止飞行')
flyManager && flyManager.stop()
}
let allStops = flyManager.getAllRouteStops()
let lastStopName = allStops[allStops.length - 1]._stopName
flyManager.stopArrived.addEventListener(function (routeStop) {
if (routeStop._stopName == lastStopName) {
alert('jieshule')
}
})
document.getElementById('reset').onclick = function () {
camera.setView({
destination: new Cesium.Cartesian3.fromDegrees(
that.cameraObj.x,
that.cameraObj.y,
that.cameraObj.z
),
orientation: {
heading: Cesium.Math.toRadians(that.cameraObj.heading),
pitch: Cesium.Math.toRadians(that.cameraObj.pitch - 90),
roll: that.cameraObj.roll,
},
})
}
})
},
marker聚合
npm install leaflet.markercluster --save
在vue页面引入css 和 leaflet.markercluster
import L from 'leaflet'
import '@supermap/iclient-leaflet'
import 'leaflet.markercluster/dist/MarkerCluster.css'
import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
import 'leaflet.markercluster'
that.markerResultLayer = L.markerClusterGroup({
spiderfyOnMaxZoom: false,
showCoverageOnHover: false,
zoomToBoundsOnClick: false,
})
that.markerResultLayer.addLayer(marker)
that.markerResultLayer.addTo(that.map)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具