| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2022-08-18 17:00:30 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2022-09-07 14:32:20 |
| | | * @LastEditTime: 2022-09-17 16:21:14 |
| | | * @FilePath: \srs-police-affairs\src\components\map\index.vue |
| | | * @Description: 公用地图组件 |
| | | * |
| | |
| | | <script> |
| | | |
| | | var siteEntitylayers = null |
| | | |
| | | let layersObjce = { |
| | | housingEstateLayer: null, |
| | | patrolWagonLayer: null, |
| | | handMachineLayer: null, |
| | | monitoringLayer: null, |
| | | panoramaLayer: null |
| | | } |
| | | |
| | | export default { |
| | | name: 'mapBox', |
| | |
| | | siteEntitylayers = new global.DC.VectorLayer('siteEntitylayers') |
| | | global.viewer.addLayer(siteEntitylayers) |
| | | |
| | | // 图层加入地图 |
| | | |
| | | layersObjce.housingEstateLayer = new global.DC.VectorLayer('housingEstateLayer') |
| | | global.viewer.addLayer(layersObjce.housingEstateLayer) |
| | | layersObjce.patrolWagonLayer = new global.DC.VectorLayer('patrolWagonLayer') |
| | | global.viewer.addLayer(layersObjce.patrolWagonLayer) |
| | | layersObjce.handMachineLayer = new global.DC.VectorLayer('handMachineLayer') |
| | | global.viewer.addLayer(layersObjce.handMachineLayer) |
| | | layersObjce.monitoringLayer = new global.DC.VectorLayer('monitoringLayer') |
| | | global.viewer.addLayer(layersObjce.monitoringLayer) |
| | | layersObjce.panoramaLayer = new global.DC.VectorLayer('panoramaLayer') |
| | | global.viewer.addLayer(layersObjce.panoramaLayer) |
| | | |
| | | |
| | | |
| | | |
| | | // 判断是否支持图像渲染像素化处理 |
| | | if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) { |
| | |
| | | window.onresize = function () { |
| | | console.log(isEleFullScreen()) |
| | | } |
| | | |
| | | // 注册事件 |
| | | this.$EventBus.on('mapAddLayer', (params) => { |
| | | that.mapAddLayer(params.layerName, params.type) |
| | | }) |
| | | |
| | | this.$EventBus.on('mapRemoveLayer', (params) => { |
| | | that.mapRemoveLayer(params.layerName, params.type) |
| | | }) |
| | | |
| | | this.$EventBus.on('mapClearLayer', (params) => { |
| | | that.mapClearLayer(params.layerName, params.type) |
| | | }) |
| | | |
| | | this.$EventBus.on('layerPointAdd', (params) => { |
| | | // eslint-disable-next-line no-unused-vars |
| | | that.layerPointAdd(params.layerName, params.type, params.params, params.incident = (e) => { }) |
| | | }) |
| | | |
| | | this.$EventBus.on('layerShow', (params) => { |
| | | that.layerShow(params.layerName, params.flag) |
| | | }) |
| | | |
| | | this.$EventBus.on('flyToPosition', (params) => { |
| | | that.flyToPosition(params.siteJd, params.siteWd, params.siteGd = 0, params.siteHeading = 0, params.sitePitch = -90, params.siteRoll = 0, params.time = 3) |
| | | }) |
| | | }, |
| | | provide () { |
| | | return { |
| | |
| | | } |
| | | }, |
| | | /** |
| | | * 在图层中添加实体(点) |
| | | * @param {*} item 图标 |
| | | * @param {*} url 图标地址 |
| | | */ |
| | | * 在图层中添加实体(点) |
| | | * @param {*} item 图标 |
| | | * @param {*} url 图标地址 |
| | | */ |
| | | addSiteEntity (item, url) { |
| | | const billboard = new global.DC.Billboard(new global.DC.Position(Number(item.lon), Number(item.lat)), url) |
| | | billboard.size = [20, 28] |
| | | billboard.attrParams = item |
| | | siteEntitylayers.addOverlay(billboard) |
| | | }, |
| | | |
| | | test () { |
| | | console.log('map.test(MAP)!!!') |
| | | }, |
| | | |
| | | /** |
| | | * 添加图层 |
| | | * @param {*} layerName 图层名称 |
| | | * @param {*} type 图层类型 |
| | | */ |
| | | mapAddLayer (layerName, type) { |
| | | if (type == 'VectorLayer') { |
| | | layersObjce[layerName] = new global.DC.VectorLayer('layerName') |
| | | global.viewer.addLayer(layersObjce[layerName]) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 删除图层 |
| | | * @param {*} layerName 图层名称 |
| | | * @param {*} type 图层类型 |
| | | */ |
| | | mapRemoveLayer (layerName, type) { |
| | | if (type == 'VectorLayer') { |
| | | layersObjce[layerName].remove() |
| | | |
| | | layersObjce[layerName] = null |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 清空图层 |
| | | * @param {*} layerName 图层名称 |
| | | * @param {*} type 图层类型 |
| | | */ |
| | | mapClearLayer (layerName, type) { |
| | | if (type == 'VectorLayer') { |
| | | layersObjce[layerName].clear() |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 图层点添加 |
| | | * @param {*} layerName 图层名称 |
| | | * @param {*} type 添加的点位类型 |
| | | * @param {*} params 添加的点位参数(内容、详情) |
| | | * @param {*} incident 添加的点位事件 |
| | | */ |
| | | layerPointAdd (layerName, type, params, incident) { |
| | | |
| | | let pointElement |
| | | |
| | | if (type == "billboard") { |
| | | pointElement = new global.DC.Billboard(new global.DC.Position(Number(params.lon), Number(params.lat)), params.url) |
| | | |
| | | pointElement.size = [20, 28] |
| | | } else if (type == "label") { |
| | | pointElement = new global.DC.Label(new global.DC.Position(Number(params.lon), Number(params.lat), 0), params.url) |
| | | |
| | | pointElement.setStyle({ |
| | | fillColor: global.DC.Color.CRIMSON, |
| | | style: global.DC.Namespace.Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | outlineColor: global.DC.Color.WHITE, // 边框颜色 |
| | | outlineWidth: 8, // 边框大小, |
| | | font: '14px sans-serif', |
| | | pixelOffset: { x: 0, y: -24 } |
| | | }) |
| | | } |
| | | pointElement.attrParams = params |
| | | layersObjce[layerName].addOverlay(pointElement) |
| | | pointElement.on(global.DC.MouseEventType.CLICK, incident) |
| | | }, |
| | | |
| | | /** |
| | | * 图层显示隐藏 |
| | | * @param {*} layerName 图层名称 |
| | | * @param {*} flag 显示隐藏 |
| | | */ |
| | | layerShow (layerName, flag) { |
| | | layersObjce[layerName].show = flag |
| | | }, |
| | | |
| | | /** |
| | | * 飞到指定位置 |
| | | * @param {*} siteJd 经度 |
| | | * @param {*} siteWd 纬度 |
| | | * @param {*} siteGd 高度,默认0 |
| | | * @param {*} siteHeading 偏航角度,默认0 |
| | | * @param {*} sitePitch 俯仰角度,默认0 |
| | | * @param {*} siteRoll 翻转角度,默认0 |
| | | * @param {*} time 飞行时间,默认3秒 |
| | | */ |
| | | flyToPosition (siteJd, siteWd, siteGd, siteHeading, sitePitch, siteRoll, time) { |
| | | global.viewer.flyToPosition( |
| | | new global.DC.Position( |
| | | Number(siteJd), |
| | | Number(siteWd), |
| | | Number(siteGd), |
| | | Number(siteHeading), |
| | | Number(sitePitch), |
| | | Number(siteRoll) |
| | | ), |
| | | function () { }, |
| | | time |
| | | ) |
| | | } |
| | | }, |
| | | |