| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2022-08-18 17:00:30 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2022-11-08 14:25:31 |
| | | * @LastEditTime: 2023-01-06 16:59:43 |
| | | * @FilePath: \srs-police-affairs\src\components\map\index.vue |
| | | * @Description: 公用地图组件 |
| | | * |
| | |
| | | --> |
| | | <template> |
| | | <div class="viewer-box" id="viewer-container"> |
| | | <slot ref="mainContent" name="mainContent"></slot> |
| | | <slot name="showButton"></slot> |
| | | <!-- 全屏控制按钮 --> |
| | | <div class="screen-full-btn"> |
| | | <el-tooltip v-if="isFullscreen" content="缩放" placement="bottom" effect="dark"> |
| | | <i |
| | | class="fa fa-compress" |
| | | style="vertical-align: middle; cursor: pointer" |
| | | @click="fullscreenchange" |
| | | ></i> |
| | | <i class="fa fa-compress" style="vertical-align: middle; cursor: pointer" @click="fullscreenchange"></i> |
| | | </el-tooltip> |
| | | <el-tooltip v-if="!isFullscreen" content="全屏" placement="bottom" effect="dark"> |
| | | <i |
| | | class="fa fa-expand" |
| | | style="vertical-align: middle; cursor: pointer" |
| | | @click="fullscreenchange" |
| | | ></i> |
| | | <i class="fa fa-expand" style="vertical-align: middle; cursor: pointer" @click="fullscreenchange"></i> |
| | | </el-tooltip> |
| | | </div> |
| | | <!-- 切换矢量图按钮 --> |
| | | <div |
| | | class="image-switch-icon-btn" |
| | | title="切换影像" |
| | | @mouseover="showImgBtn = true" |
| | | @mouseleave="showImgBtn = false" |
| | | > |
| | | <img src="/img/base_map.png" alt /> |
| | | </div> |
| | | <div |
| | | class="image-switch-img-btn" |
| | | v-show="showImgBtn" |
| | | @mouseover="showImgBtn = true" |
| | | @mouseleave="showImgBtn = false" |
| | | > |
| | | <div class="img" @click="switchImg"> |
| | | <span :class="{on:imgtype == 0}">影像</span> |
| | | <div class="image-switch-icon-btn" title="切换影像" @mouseover="showImgBtn = true" @mouseleave="showImgBtn = false"> |
| | | <div class="icon-box"> |
| | | <img src="/img/base_map.png" alt /> |
| | | </div> |
| | | <div class="elec" @click="switchElec"> |
| | | <span :class="{on:imgtype == 1}">矢量</span> |
| | | |
| | | <div class="image-switch-img-btn" v-show="showImgBtn" @mouseover="showImgBtn = true" |
| | | @mouseleave="showImgBtn = false"> |
| | | <div class="img" @click="switchImg"> |
| | | <span :class="{ on: imgtype == 0 }">影像</span> |
| | | </div> |
| | | <div class="elec" @click="switchElec"> |
| | | <span :class="{ on: imgtype == 1 }">矢量</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | monitoringLayer: null, |
| | | panoramaLayer: null |
| | | } |
| | | let polygonObj = {} |
| | | |
| | | let tilesetLayer = null |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | // let terrain = global.DC.TerrainFactory.createUrlTerrain({ |
| | | // url: 'http://data.marsgis.cn/terrain' |
| | | // }) |
| | | // global.viewer.addTerrain(terrain) |
| | | |
| | | // 天地图 影像 |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | url: 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c', |
| | | subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], |
| | | format: 'image/jpeg', |
| | | show: true, |
| | | maximumLevel: 18 |
| | | }) |
| | | ) |
| | | // global.viewer.imageryLayers.addImageryProvider( |
| | | // new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | // url: 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c', |
| | | // subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], |
| | | // format: 'image/jpeg', |
| | | // show: true, |
| | | // maximumLevel: 18 |
| | | // }) |
| | | // ) |
| | | |
| | | |
| | | // 上饶部署,内网使用的 |
| | | // global.viewer.imageryLayers.addImageryProvider( |
| | | // new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({ |
| | | // url: "http://36.14.131.101:8090/MapTileService/wmts?STORETYPE=merged-dat&PROJECTION=4326", |
| | | // layer: "wmts_4326_361100", |
| | | // style: "default", |
| | | // format: "image/png", |
| | | // tileMatrixSetID: "c", |
| | | // tileMatrixLabels: new Array(18).fill(0).map((v, i) => i + 1), |
| | | // tilingScheme: new global.DC.Namespace.Cesium.GeographicTilingScheme(), |
| | | // }) |
| | | // ) |
| | | |
| | | // 加载顺丰底图 |
| | | // global.viewer.imageryLayers.addImageryProvider( |
| | | // new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | // url: "http://36.14.131.102:8899/tile?x={x}&y={y}&z={z}&mid=basemap&p=0&f=pbf" |
| | | // // url: "https://webmap-tile.sf-express.com/MapTileService/rt?x={x}&y={y}&z={z}" |
| | | // }) |
| | | // ) |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({ |
| | | url: "http://10.141.11.11:8090/MapTileService/wmts?STORETYPE=merged-dat&PROJECTION=4326", |
| | | layer: "wmts_4326_361100", |
| | | style: "default", |
| | | format: "image/png", |
| | | tileMatrixSetID: "c", |
| | | tileMatrixLabels: new Array(18).fill(0).map((v, i) => i + 1), |
| | | tilingScheme: new global.DC.Namespace.Cesium.GeographicTilingScheme(), |
| | | }) |
| | | ) |
| | | |
| | | // 设置地图初始位置,角度等 |
| | | global.viewer.camera.setView({ |
| | | // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州 |
| | | // fromDegrees()方法,将经纬度和高程转换为世界坐标 |
| | | destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees( |
| | | 116.112550, 28.196631, 50000 |
| | | 117.951478782, 28.447896798, 5000 |
| | | ), |
| | | orientation: { |
| | | // 指向 |
| | | heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0), |
| | | // 视角 |
| | | pitch: global.DC.Namespace.Cesium.Math.toRadians(-45), |
| | | pitch: global.DC.Namespace.Cesium.Math.toRadians(-90), |
| | | roll: 0.0 |
| | | } |
| | | }) |
| | | |
| | | let sqTitleLayer = new global.DC.TilesetLayer('sqTitleLayer') |
| | | global.viewer.addLayer(sqTitleLayer) |
| | | let sqTileset = new global.DC.Tileset( |
| | | 'http://10.141.11.11:18080/sf3d/361102/model/wanda/tileset.json' |
| | | ) |
| | | sqTileset.setHeight(12) |
| | | sqTitleLayer.addOverlay(sqTileset) |
| | | |
| | | // sqTileset.on(global.DC.MouseEventType.CLICK, (e) => { |
| | | // console.log(e) |
| | | // }) |
| | | |
| | | let positions = [[117.951478782, 28.447896798, 0], [117.951469798, 28.447894686, 0], [117.951397357, 28.447698099, 0], [117.951505114, 28.447674695, 0], [117.951485465, 28.447619271, 0], [117.951706955, 28.447558541, 0], [117.951722755, 28.447611995, 0], [117.951834021, 28.447588427, 0], [117.951896863, 28.447789523, 0], [117.951478782, 28.447896798, 0]] |
| | | |
| | | let MIN_F_H = positions.map(item => { |
| | | item[2] = 70 |
| | | return item |
| | | }) |
| | | |
| | | let MAN_F_H = positions.map(item => { |
| | | item[2] = 80 |
| | | return item |
| | | }) |
| | | |
| | | // 原生Cesium加载多边体 |
| | | let floorEntitysLayers = new global.DC.Namespace.Cesium.CustomDataSource("floorEntitysLayers") |
| | | global.viewer.dataSources.add(floorEntitysLayers) |
| | | let flootEntitysEntites = floorEntitysLayers.entities |
| | | |
| | | let floorPositions = positions.reduce((prev, curr, index, arr) => { |
| | | curr.forEach(item => { |
| | | prev.push(item) |
| | | }) |
| | | return prev |
| | | }, []) |
| | | |
| | | flootEntitysEntites.add({ |
| | | polygon: { |
| | | hierarchy: global.DC.Namespace.Cesium.Cartesian3.fromDegreesArrayHeights(floorPositions), |
| | | heightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND, |
| | | extrudedHeightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND, |
| | | height: 70, |
| | | extrudedHeight: 80, |
| | | material: global.DC.Namespace.Cesium.Color.RED.withAlpha(0.5), |
| | | } |
| | | }) |
| | | |
| | | // console.log(floorPositions) |
| | | |
| | | // let floorPositions = MIN_F_H.concat(MAN_F_H) |
| | | |
| | | // let floorPolygonlayer = new global.DC.VectorLayer('floorPolygonlayer') |
| | | // global.viewer.addLayer(floorPolygonlayer) |
| | | |
| | | // let floorPolygon = new global.DC.Polygon( |
| | | // floorPositions |
| | | // ) |
| | | |
| | | // floorPolygon.setStyle({ |
| | | // height: 70, |
| | | // extrudedHeight: 80, |
| | | // material: global.DC.Color.GREEN.withAlpha(0.5), |
| | | // heightReference: 2, |
| | | // perPositionHeight: true |
| | | // }) |
| | | |
| | | // floorPolygonlayer.addOverlay(floorPolygon) |
| | | |
| | | // global.viewer.flyTo(floorPolygonlayer) |
| | | |
| | | // global.viewer.flyTo(sqTileset) |
| | | |
| | | global.viewer.use(new global.DC.Measure()) |
| | | |
| | | global.viewer.locationBar.enable = true |
| | | // global.viewer.locationBar.enable = true |
| | | // 缩放 |
| | | global.viewer.zoomController.enable = true |
| | | // 比例尺 |
| | |
| | | }) |
| | | |
| | | this.$EventBus.$on('layerPolygonAdd', (params) => { |
| | | that.layerPolygonAdd(params.layerName, params.positions, params.material, params.distanceDisplayCondition) |
| | | if ('polygonName' in params) { |
| | | that.layerPolygonAdd(params.layerName, params.positions, params.material, params.distanceDisplayCondition, params.polygonName, params.params, params.incident) |
| | | } else { |
| | | that.layerPolygonAdd(params.layerName, params.positions, params.material, params.distanceDisplayCondition, 'polygon', params.params, params.incident) |
| | | } |
| | | }) |
| | | |
| | | this.$EventBus.$on('layerPolylineAdd', (params) => { |
| | | that.layerPolylineAdd(params.layerName, params.positions, params.material, params.width) |
| | | that.layerPolylineAdd(params.layerName, params.positions, params.material, params.width, params.params, params.incident) |
| | | }) |
| | | |
| | | this.$EventBus.$on('layerShow', (params) => { |
| | |
| | | }) |
| | | |
| | | this.$EventBus.$on('flytoLayer', (params) => { |
| | | that.flytoLayer(params.layerName, params.duration) |
| | | that.flytoLayer(params.polygonName, params.duration) |
| | | }) |
| | | |
| | | }, |
| | |
| | | methods: { |
| | | // 模型的点击事件 |
| | | tilesetClick (e) { |
| | | if (this.$route.path != "/lyout/house") { |
| | | this.$router.push({ path: '/lyout/house', query: { searchName: 'xxx小区' } }) |
| | | if (this.$route.path != "/layout/house") { |
| | | this.$router.push({ path: '/layout/house', query: { searchName: 'xxx小区' } }) |
| | | } |
| | | }, |
| | | switchImg () { |
| | |
| | | outlineColor: global.DC.Color.WHITE, // 边框颜色 |
| | | outlineWidth: 4, // 边框大小, |
| | | font: '16px sans-serif', |
| | | pixelOffset: { x: 0, y: -24 }, |
| | | pixelOffset: { x: 0, y: -30 }, |
| | | distanceDisplayCondition: distanceDisplayCondition |
| | | }) |
| | | pointElement.attrParams = params |
| | |
| | | * @param {*} material 颜色 |
| | | * @param {*} distanceDisplayCondition 可见距离 |
| | | */ |
| | | layerPolygonAdd (layerName, positions, material, distanceDisplayCondition) { |
| | | layerPolygonAdd (layerName, positions, material, distanceDisplayCondition, polygonName, params, incident = (e) => { }) { |
| | | if (!layersObjcect[layerName] || layersObjcect[layerName] == null) { |
| | | this.mapAddLayer(layerName, 'VectorLayer') |
| | | |
| | | layersObjcect[layerName].allowDrillPicking = true |
| | | } |
| | | |
| | | let polygon = new global.DC.Polygon(positions) |
| | | |
| | | polygon.setStyle({ |
| | | // let polygon = new global.DC.Polygon(positions) |
| | | // let polygonObj = {}//要在全局定义 |
| | | polygonObj[polygonName] = new global.DC.Polygon(positions) |
| | | // polygon.setStyle({ |
| | | polygonObj[polygonName].setStyle({ |
| | | material: material, |
| | | distanceDisplayCondition: distanceDisplayCondition, |
| | | perPositionHeight: true, |
| | | }) |
| | | |
| | | layersObjcect[layerName].addOverlay(polygon) |
| | | // layersObjcect[layerName].addOverlay(polygon) |
| | | polygonObj[polygonName].attrParams = params |
| | | polygonObj[polygonName].on(global.DC.MouseEventType.CLICK, incident) |
| | | layersObjcect[layerName].addOverlay(polygonObj[polygonName]) |
| | | }, |
| | | |
| | | /** |
| | |
| | | * @param {*} material 颜色 |
| | | * @param {*} width 宽度 |
| | | */ |
| | | layerPolylineAdd (layerName, positions, material, width) { |
| | | layerPolylineAdd (layerName, positions, material, width, params, incident = (e) => { }) { |
| | | if (!layersObjcect[layerName] || layersObjcect[layerName] == null) { |
| | | this.mapAddLayer(layerName, 'VectorLayer') |
| | | |
| | |
| | | material: material, |
| | | clampToGround: false |
| | | }) |
| | | polyline.attrParams = params |
| | | polyline.on(global.DC.MouseEventType.CLICK, incident) |
| | | |
| | | layersObjcect[layerName].addOverlay(polyline) |
| | | }, |
| | | |
| | |
| | | // sdTilesetLayer |
| | | |
| | | /** |
| | | * 飞到指定图层 |
| | | * @param {*} layerName 图层名称 |
| | | * 飞到指定范围 |
| | | * @param {*} polygonName 范围名称 |
| | | * @param {*} duration 时间 |
| | | */ |
| | | flytoLayer (layerName, duration = 3) { |
| | | global.viewer.flyTo(layersObjcect[layerName], duration) |
| | | flytoLayer (polygonName, duration = 3) { |
| | | global.viewer.flyTo(polygonObj[polygonName], duration) |
| | | }, |
| | | |
| | | /** |