实时定位,位置处理;
不同校区,显示位置做处理;
切换校区显示内容做处理;
| | |
| | | let campusLayers = [ |
| | | { |
| | | key: 1, |
| | | tileUrl: "https://fkxt.jxstnu.edu.cn/changjing/arcgis/rest/services/ksd1206/MapServer/tile/{z}/{y}/{x}", |
| | | center: [10800, -4900], |
| | | resolution: 4.233341800016934, |
| | | origin: [-5123200.0, 10002100], |
| | | projection: 'EPSG:4548', |
| | | tileUrl: "https://fkxt.jxstnu.edu.cn/changjing/arcgis/rest/services/ksdhjzxq/MapServer/tile/{z}/{y}/{x}", |
| | | center: [112.605918275550715, -0.0457081387615907618595], |
| | | resolution: 0.00003807137609328448, |
| | | origin: [-400.0, 399.9999999999998], |
| | | resolutions: [ |
| | | 16.933367200067735, 8.466683600033868, 4.233341800016934, |
| | | 2.116670900008467, 1.0583354500042335, 0.5291677250021167, |
| | | 0.26458386250105836 |
| | | 0.00015228550437313792, 0.00007614275218656896, 0.00003807137609328448, |
| | | 0.00001903568804664224, 0.00000951784402332112, 0.00000475892201166056 |
| | | ], |
| | | fullExtent: [ |
| | | -0.5, -11468.5, 18506.5, |
| | | 0.5, |
| | | 112.51303616638316, -0.103420786429659, 112.67880038471827, |
| | | 0.000004508906477476281 |
| | | ], |
| | | polygonUrl: 'https://fkxt.jxstnu.edu.cn/changjing/lkarcgisapp' |
| | | }, |
| | | |
| | | { |
| | | key: 2, |
| | | tileUrl: "https://dev.jxpskj.com:8023/arcgis156/rest/services/cc/MapServer/tile/{z}/{y}/{x}", |
| | | center: [115.79624983, 28.6416099], |
| | | resolution: 0.000007138383017490841, |
| | | origin: [-400.0, 400.0], |
| | | projection: '4548', |
| | | tileUrl: "https://fkxt.jxstnu.edu.cn/changjing/arcgis/rest/services/ksdflxq/MapServer/tile/{z}/{y}/{x}", |
| | | center: [112.6202242373625, -0.0811745423945008147645], |
| | | resolution: 0.00007614275218656896, |
| | | origin: [-400.0, 399.9999999999998], |
| | | resolutions: [ |
| | | 0.000014276766034981682, 0.000007138383017490841, 0.00000475892201166056, |
| | | 0.00000237946100583028, |
| | | 0.00015228550437313792, 0.00007614275218656896, 0.00003807137609328448, |
| | | 0.00001903568804664224, 0.00000951784402332112, 0.00000475892201166056 |
| | | ], |
| | | fullExtent: [ |
| | | 115.76861782444642, 28.63584422760626, 115.82432471553928, 28.663308794331794, |
| | | 112.51302551881798, -0.16235359398493399, 112.72742295590702, 0.000004509195932360471 |
| | | ], |
| | | polygonUrl: '' |
| | | polygonUrl: 'https://fkxt.jxstnu.edu.cn/changjing/lkarcgisapp' |
| | | } |
| | | ] |
| | | |
| | |
| | | this.$store.commit('SET_MONITORPOPUP', false) |
| | | this.$store.commit('SET_PANORAMAPOPUP', false) |
| | | |
| | | this.$store.dispatch('delVisitedViews', this.$route) |
| | | |
| | | this.$store.commit('SET_ARCNAVBARFLAG', false) |
| | | this.$store.commit('SET_SEARCHPOPUPFLAG', false) |
| | | this.$store.commit('SET_SEARCHPOPUPFLAG', false) |
| | | |
| | | this.$router.push('/pcLayout/default') |
| | | |
| | | this.$refs.leftNav.initialize(newData) |
| | | |
| | |
| | | if (campusLoadLayer) this.map2D.removeLayer(campusLoadLayer) |
| | | let curCampus = campusLayers.find(item => item.key == campusKey) |
| | | |
| | | const tileGrid = new TilegridTileGrid({ |
| | | let tileGrid = new TilegridTileGrid({ |
| | | tileSize: 256, |
| | | origin: curCampus.origin, |
| | | extent: curCampus.fullExtent, |
| | | resolutions: curCampus.resolutions, |
| | | }) |
| | | // 瓦片数据源 |
| | | const tileArcGISXYZ = new XYZ({ |
| | | let tileArcGISXYZ = new XYZ({ |
| | | tileGrid: tileGrid, |
| | | // projection: curCampus.projection, |
| | | projection: "EPSG:4326", |
| | | url: curCampus.tileUrl, |
| | | }) |
| | | |
| | |
| | | // 初始化中心点坐标 |
| | | center: curCampus.center, |
| | | resolution: curCampus.resolution, |
| | | // projection: curCampus.projection, |
| | | projection: "EPSG:4326", |
| | | extent: curCampus.fullExtent, |
| | | })) |
| | | } |
| | |
| | | } |
| | | }, |
| | | props: ['mapCenter', 'frislayertHeight'], |
| | | |
| | | inject: ['mobileMapElement'], |
| | | |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'openmobileGoTo', |
| | |
| | | }, |
| | | methods: { |
| | | openOurSee () { |
| | | let url |
| | | |
| | | if (this.mobileMapElement.campusValue == 1) { |
| | | url = 'https://vr.jxpskj.com:1443/JXKESFDX_HJZXQ/' |
| | | } else { |
| | | url = 'https://vr.jxpskj.com:1443/JXKJSFDX_FLXQ/' |
| | | } |
| | | |
| | | this.$store.commit( |
| | | 'MSET_OPENMOBILEPANORAMA', |
| | | // 'https://vr.jxpskj.com/JXSFKZQJ/QJ/' // sd |
| | | 'https://vr.jxpskj.com:1443/JXKESFDX_HJZXQ/' // jg |
| | | url // jg |
| | | ) |
| | | }, |
| | | |
| | |
| | | var options = { timeout: 8000 }// 设置定位超时 |
| | | |
| | | window.geolocation.getLocation(showPosition, showErrow, options) |
| | | // this.$store.commit('GET_NOWPOSITION', (res) => { |
| | | // that.$store.dispatch('pcMoveView', { |
| | | // jd: res[0], |
| | | // wd: res[1], |
| | | // viewer: global.viewer |
| | | // }) |
| | | this.$store.commit('GET_NOWPOSITION', (res) => { |
| | | that.$store.dispatch('pcMoveView', { |
| | | jd: res[0], |
| | | wd: res[1], |
| | | viewer: global.viewer |
| | | }) |
| | | |
| | | // const data = [ |
| | | // { |
| | | // name: '我的位置', |
| | | // jd: res[0], |
| | | // wd: res[1] |
| | | // } |
| | | // ] |
| | | // that.$store.dispatch('addLabelLayerIconMobelUse', { |
| | | // list: data, |
| | | // clear: true, |
| | | // mviewer: global.viewer |
| | | // }) |
| | | // }) |
| | | const data = [ |
| | | { |
| | | name: '我的位置', |
| | | jd: res[0], |
| | | wd: res[1] |
| | | } |
| | | ] |
| | | |
| | | that.$store.dispatch('addLabelLayerIconMobelUse', { |
| | | list: data, |
| | | clear: true, |
| | | mviewer: global.viewer |
| | | }) |
| | | }) |
| | | |
| | | function showPosition (result) { |
| | | const position = GCJ02ToWGS84(result.lng, result.lat) |
| | |
| | | }, |
| | | |
| | | zoomIns (val) { |
| | | // this.$store.dispatch("mapFlyTo", { |
| | | // //飞入 |
| | | // lntLat: [115.87988885, 28.72502592, 2100], |
| | | // // lntLat: [115.87186406, 28.74449337, 1200], |
| | | // // lntLat: [121.50492752204283, 31.21567802276832, 2530], |
| | | // heading: 0, |
| | | // pitch: -45, |
| | | // roll: 0, |
| | | // noOpen: true, |
| | | // }); |
| | | // if (val) { |
| | | // if (this.dimension != val) { |
| | | // this.$store.dispatch("MSET_DIMENSIONS", val); |
| | | // } |
| | | // return; |
| | | // } |
| | | this.map2D.getView().setCenter([11000, -4900]) |
| | | this.map2D.getView().setResolution(2.116670900008467) |
| | | if (this.mobileMapElement.campusValue == 1) { |
| | | this.map2D.getView().setCenter([112.613918275550715, -0.0457081387615907618595]) |
| | | this.map2D.getView().setResolution(0.00001903568804664224) |
| | | } else { |
| | | this.map2D.getView().setCenter([112.6202242373625, -0.0781745423945008147645]) |
| | | this.map2D.getView().setResolution(0.00001903568804664224) |
| | | } |
| | | }, |
| | | |
| | | openActivity () { |
| | |
| | | let campusLayers = [ |
| | | { |
| | | key: 1, |
| | | tileUrl: "https://fkxt.jxstnu.edu.cn/changjing/arcgis/rest/services/ksd1206/MapServer/tile/{z}/{y}/{x}", |
| | | center: [11000, -4900], |
| | | resolution: 2.116670900008467, |
| | | origin: [-5123200.0, 10002100], |
| | | projection: 'EPSG:4548', |
| | | tileUrl: "https://fkxt.jxstnu.edu.cn/changjing/arcgis/rest/services/ksdhjzxq/MapServer/tile/{z}/{y}/{x}", |
| | | center: [112.613918275550715, -0.0457081387615907618595], |
| | | resolution: 0.00001903568804664224, |
| | | origin: [-400.0, 399.9999999999998], |
| | | resolutions: [ |
| | | 16.933367200067735, 8.466683600033868, 4.233341800016934, |
| | | 2.116670900008467, 1.0583354500042335, 0.5291677250021167, |
| | | 0.26458386250105836 |
| | | 0.00015228550437313792, 0.00007614275218656896, 0.00003807137609328448, |
| | | 0.00001903568804664224, 0.00000951784402332112, 0.00000475892201166056 |
| | | ], |
| | | fullExtent: [ |
| | | -0.5, -11468.5, 18506.5, |
| | | 0.5, |
| | | 112.51303616638316, -0.103420786429659, 112.67880038471827, |
| | | 0.000004508906477476281 |
| | | ], |
| | | polygonUrl: 'https://fkxt.jxstnu.edu.cn/changjing/lkarcgisapp' |
| | | }, |
| | | |
| | | { |
| | | key: 2, |
| | | tileUrl: "https://dev.jxpskj.com:8023/arcgis156/rest/services/cc/MapServer/tile/{z}/{y}/{x}", |
| | | center: [115.79624983, 28.6416099], |
| | | resolution: 0.000007138383017490841, |
| | | origin: [-400.0, 400.0], |
| | | tileUrl: "https://fkxt.jxstnu.edu.cn/changjing/arcgis/rest/services/ksdflxq/MapServer/tile/{z}/{y}/{x}", |
| | | center: [112.6202242373625, -0.0781745423945008147645], |
| | | resolution: 0.00001903568804664224, |
| | | origin: [-400.0, 399.9999999999998], |
| | | resolutions: [ |
| | | 0.000014276766034981682, 0.000007138383017490841, 0.00000475892201166056, |
| | | 0.00000237946100583028, |
| | | 0.00015228550437313792, 0.00007614275218656896, 0.00003807137609328448, |
| | | 0.00001903568804664224, 0.00000951784402332112, 0.00000475892201166056 |
| | | ], |
| | | fullExtent: [ |
| | | 115.76861782444642, 28.63584422760626, 115.82432471553928, 28.663308794331794, |
| | | 112.51302551881798, -0.16235359398493399, 112.72742295590702, 0.000004509195932360471 |
| | | ], |
| | | polygonUrl: '' |
| | | polygonUrl: 'https://fkxt.jxstnu.edu.cn/changjing/lkarcgisapp' |
| | | } |
| | | ] |
| | | |
| | |
| | | }, |
| | | map2D: this.$store.state.openlayerData.openlayers.map2D, |
| | | campusData: [], |
| | | campusValue: '' |
| | | campusValue: 1 |
| | | } |
| | | }, |
| | | |
| | |
| | | }) |
| | | // 瓦片数据源 |
| | | const tileArcGISXYZ = new XYZ({ |
| | | projection: "EPSG:4326", |
| | | tileGrid: tileGrid, |
| | | url: curCampus.tileUrl, |
| | | }) |
| | |
| | | |
| | | this.map2D.setView(new OlView({ |
| | | // 初始化中心点坐标 |
| | | projection: "EPSG:4326", |
| | | center: curCampus.center, |
| | | resolution: curCampus.resolution, |
| | | extent: curCampus.fullExtent, |
| | |
| | | |
| | | setCampusValue (val) { |
| | | this.campusValue = val |
| | | |
| | | this.$store.commit('SET_CURRENTCAMPUS', val) |
| | | }, |
| | | |
| | | handleCommand (command) { |
| | |
| | | return { |
| | | publicPath: process.env.BASE_URL, |
| | | campusData: [], |
| | | campusValue: '' |
| | | campusValue: 1 |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | addIconsLayerIconPopup: (state) => state.popupParams.addIconsLayerIconPopup, // 自定义标签编辑窗口 |
| | | addIconsLayerIconPosition: (state) => |
| | | state.popupParams.addIconsLayerIconPosition, // 自定义标签编辑窗口 |
| | | currentCampus: (state) => state.mobilePosition.currentCampus, |
| | | }; |
| | | export default getters; |
| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2022-09-09 17:54:08 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2022-09-14 16:05:41 |
| | | * @FilePath: \smart-campus\src\store\modules\mobilePosition.js |
| | | * @LastEditTime: 2023-12-07 18:11:59 |
| | | * @FilePath: \sd-jg-school-web-ksd\src\store\modules\mobilePosition.js |
| | | * @Description: |
| | | * |
| | | * Copyright (c) 2022 by shuishen 1109946754@qq.com, All Rights Reserved. |
| | | */ |
| | | |
| | | let extent = [ |
| | | { |
| | | key: 1, |
| | | xMin: 112.51303616638316, |
| | | yMin: -0.103420786429659, |
| | | xMax: 112.67880038471827, |
| | | yMax: 0.000004508906477476281, |
| | | |
| | | x: (x, y) => { |
| | | return -250.6503 + 2.0389 * x + 4.4338 * y; |
| | | }, |
| | | |
| | | x: (x, y) => { |
| | | return 228.1454 - 2.321 * x + 1.4165 * y; |
| | | }, |
| | | }, |
| | | |
| | | { |
| | | key: 2, |
| | | xMin: 112.51302551881798, |
| | | yMin: -0.16235359398493399, |
| | | xMax: 112.72742295590702, |
| | | yMax: 0.000004509195932360471, |
| | | |
| | | x: (x, y) => { |
| | | return -789.1274 + 6.0609 * x + 6.9479 * y; |
| | | }, |
| | | |
| | | x: (x, y) => { |
| | | return 298.9294 - 3.5295 * x + 3.8211 * y; |
| | | }, |
| | | }, |
| | | ]; |
| | | |
| | | import { GCJ02ToWGS84 } from "@/utils/CoordTransform"; |
| | | |
| | | const mobilePosition = { |
| | | state: { |
| | | getSPosition: null |
| | | }, |
| | | mutations: { |
| | | GET_NOWPOSITION (state, val) { |
| | | var outData = |
| | | val || |
| | | function (res) { |
| | | console.log(res) |
| | | } |
| | | state: { |
| | | getSPosition: null, |
| | | currentCampus: 1, |
| | | }, |
| | | mutations: { |
| | | GET_NOWPOSITION(state, val) { |
| | | var outData = |
| | | val || |
| | | function (res) { |
| | | console.log(res); |
| | | }; |
| | | |
| | | console.log(state, 222) |
| | | let cur = extent.find((item) => item.key == state.currentCampus); |
| | | |
| | | global.Geolocation.getLocation(function success (result) { |
| | | const position = global.DC.CoordTransform.GCJ02ToWGS84(result.lng, result.lat) |
| | | global.Geolocation.getLocation( |
| | | function success(result) { |
| | | let positionWgs = GCJ02ToWGS84(result.lng, result.lat); |
| | | |
| | | if (position[0] > 115.78815057 && position[0] < 115.80346610 && position[1] > 28.63771847 && position[1] < 28.64981682) { |
| | | outData([position[0], position[1]]) |
| | | } else { |
| | | Message({ |
| | | message: '您当前位置超出学校范围', |
| | | type: 'warning', |
| | | duration: 2000 |
| | | }) |
| | | let position = { |
| | | lng: cur.x(positionWgs[0], positionWgs[1]), |
| | | lat: cur.y(positionWgs[0], positionWgs[1]), |
| | | }; |
| | | |
| | | outData(['失败']) |
| | | } |
| | | }, function error (result) { |
| | | if (result.code == 1) { |
| | | confirm('您拒绝了定位功能') |
| | | } else if (result.code == 3 || result.code == 5) { |
| | | confirm('请求超时') |
| | | } |
| | | }, { |
| | | timeout: 8000, // 默认值为10s; |
| | | failTipFlag: true |
| | | }) |
| | | if ( |
| | | position.lng > cur.xMin && |
| | | position.lng < cur.xMax && |
| | | position.lat > cur.yMin && |
| | | position.lat < cur.yMax |
| | | ) { |
| | | outData([position.lng, position.lat]); |
| | | } else { |
| | | Message({ |
| | | message: "您当前位置超出学校范围", |
| | | type: "warning", |
| | | duration: 2000, |
| | | }); |
| | | |
| | | outData(["失败"]); |
| | | } |
| | | }, |
| | | CLOSE_NOWPOSITION (state) { |
| | | // if (state.getSPosition && navigator.geolocation) { |
| | | // navigator.geolocation.clearWatch(state.getSPosition); |
| | | // state.getSPosition = null; |
| | | // } |
| | | function error(result) { |
| | | if (result.code == 1) { |
| | | confirm("您拒绝了定位功能"); |
| | | } else if (result.code == 3 || result.code == 5) { |
| | | confirm("请求超时"); |
| | | } |
| | | }, |
| | | { |
| | | timeout: 8000, // 默认值为10s; |
| | | failTipFlag: true, |
| | | } |
| | | ); |
| | | }, |
| | | actions: {} |
| | | } |
| | | |
| | | export default mobilePosition |
| | | CLOSE_NOWPOSITION(state) { |
| | | // if (state.getSPosition && navigator.geolocation) { |
| | | // navigator.geolocation.clearWatch(state.getSPosition); |
| | | // state.getSPosition = null; |
| | | // } |
| | | }, |
| | | |
| | | SET_CURRENTCAMPUS(state, val) { |
| | | state.currentCampus = val; |
| | | }, |
| | | }, |
| | | actions: {}, |
| | | }; |
| | | |
| | | export default mobilePosition; |
| | |
| | | }), |
| | | }) |
| | | ); |
| | | |
| | | window.labelLayer.getSource().addFeature(iconFeature); |
| | | }, |
| | | |