支持从第三方读取地图配置
This commit is contained in:
@@ -36,15 +36,16 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
overlayId: null,
|
||||
dragInteraction: new DragInteraction()
|
||||
dragInteraction: new DragInteraction(),
|
||||
mapTileList: [],
|
||||
mapTileIndex: 0
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.init()
|
||||
}, 100)
|
||||
this.init()
|
||||
})
|
||||
|
||||
},
|
||||
mounted() {
|
||||
|
||||
@@ -53,6 +54,23 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.$store.dispatch('server/getMapConfig')
|
||||
.then(mapConfigList => {
|
||||
console.log(mapConfigList.length)
|
||||
if (mapConfigList.length === 0) {
|
||||
if (window.mapParam.tilesUrl) {
|
||||
this.mapTileList.push({
|
||||
tilesUrl: window.mapParam.tilesUrl,
|
||||
coordinateSystem: window.mapParam.coordinateSystem
|
||||
})
|
||||
}
|
||||
}else {
|
||||
this.mapTileList = mapConfigList
|
||||
}
|
||||
this.initMap()
|
||||
})
|
||||
},
|
||||
initMap(){
|
||||
let center = fromLonLat([116.41020, 39.915119])
|
||||
if (window.mapParam.center) {
|
||||
center = fromLonLat(window.mapParam.center)
|
||||
@@ -65,13 +83,13 @@ export default {
|
||||
minZoom: window.mapParam.minZoom || 1
|
||||
})
|
||||
let tileLayer = null
|
||||
if (window.mapParam.tilesUrl) {
|
||||
if (this.mapTileList.length > 0 && this.mapTileList[this.mapTileIndex].tilesUrl) {
|
||||
tileLayer = new Tile({
|
||||
source: new XYZ({
|
||||
projection: getProj('EPSG:3857'),
|
||||
wrapX: false,
|
||||
tileSize: 256 || window.mapParam.tileSize,
|
||||
url: window.mapParam.tilesUrl
|
||||
url: this.mapTileList[this.mapTileIndex].tilesUrl
|
||||
})
|
||||
})
|
||||
} else {
|
||||
@@ -179,7 +197,6 @@ export default {
|
||||
},
|
||||
openInfoBox(position, content, offset) {
|
||||
if (this.overlayId !== null) {
|
||||
console.log(this.overlayId)
|
||||
this.closeInfoBox(this.overlayId)
|
||||
this.overlayId = null
|
||||
}
|
||||
@@ -354,6 +371,9 @@ export default {
|
||||
olMap.addLayer(vectorLayer)
|
||||
return vectorLayer
|
||||
}
|
||||
},
|
||||
getCurrentCoordinateSystem() {
|
||||
return this.mapTileList[this.mapTileIndex].coordinateSystem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@
|
||||
<el-option key="UTF-8" label="UTF-8" value="utf-8" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="坐标系" prop="geoCoordSys">
|
||||
<el-select v-model="form.geoCoordSys" style="float: left; width: 100%">
|
||||
<el-option key="WGS84" label="WGS84" value="gb2312" />
|
||||
<el-option key="GCJ02" label="GCJ02" value="utf-8" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="其他选项">
|
||||
<el-checkbox v-model="form.ssrcCheck" label="SSRC校验" style="float: left" />
|
||||
<el-checkbox v-model="form.asMessageChannel" label="作为消息通道" style="float: left" />
|
||||
@@ -169,7 +169,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import deviceEdit from '../dialog/deviceEdit.vue'
|
||||
import deviceEdit from './edit.vue'
|
||||
import syncChannelProgress from '../dialog/SyncChannelProgress.vue'
|
||||
import configInfo from '../dialog/configInfo.vue'
|
||||
import Vue from 'vue'
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
<MapComponent ref="mapComponent" @loaded="initChannelLayer"></MapComponent>
|
||||
</div>
|
||||
<div class="map-tool-box">
|
||||
<div class="map-tool-btn-group">
|
||||
<div class="map-tool-btn" @click="initChannelLayer">
|
||||
<i class="iconfont icon-tuceng"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="map-tool-btn-group">
|
||||
<div class="map-tool-btn" @click="initChannelLayer">
|
||||
<i class="iconfont icon-shuaxin3"></i>
|
||||
@@ -60,6 +65,7 @@ import DeviceTree from '../common/DeviceTree.vue'
|
||||
import queryTrace from './queryTrace.vue'
|
||||
import MapComponent from '../common/MapComponent.vue'
|
||||
import devicePlayer from '../common/channelPlayer/index.vue'
|
||||
import gcoord from 'gcoord'
|
||||
|
||||
export default {
|
||||
name: 'Map',
|
||||
@@ -151,16 +157,18 @@ export default {
|
||||
initChannelLayer: function () {
|
||||
// 获取所有有位置的通道
|
||||
this.closeInfoBox()
|
||||
this.$store.dispatch('commonChanel/getAllForMap', {
|
||||
geoCoordSys: window.mapParam.coordinateSystem
|
||||
}).then(data => {
|
||||
this.$store.dispatch('commonChanel/getAllForMap', {}).then(data => {
|
||||
let array = []
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let item = data[i]
|
||||
if (item.gbLongitude && item.gbLatitude) {
|
||||
let position = [item.gbLongitude, item.gbLatitude]
|
||||
let gcj02Position = gcoord.transform(position, gcoord.WGS84, gcoord.GCJ02)
|
||||
item.gbLongitude = gcj02Position[0]
|
||||
item.gbLatitude = gcj02Position[1]
|
||||
array.push({
|
||||
id: item.gbId,
|
||||
position: [item.gbLongitude, item.gbLatitude],
|
||||
position: gcj02Position,
|
||||
data: item,
|
||||
image: {
|
||||
anchor: [0.5, 1],
|
||||
@@ -291,6 +299,12 @@ export default {
|
||||
})
|
||||
},
|
||||
submitEdit: function(channel) {
|
||||
let position = [channel.gbLongitude, channel.gbLatitude]
|
||||
if (this.$refs.mapComponent.getCurrentCoordinateSystem() === 'GCJ02') {
|
||||
let wgs84Position = gcoord.transform(position, gcoord.GCJ02, gcoord.WGS84)
|
||||
channel.gbLongitude = wgs84Position[0]
|
||||
channel.gbLatitude = wgs84Position[1]
|
||||
}
|
||||
this.$store.dispatch('commonChanel/update', channel)
|
||||
.then(data => {
|
||||
this.$message.success({
|
||||
@@ -302,7 +316,7 @@ export default {
|
||||
this.$refs.mapComponent.dragInteraction.removeFeatureId(channel.gbId)
|
||||
this.$refs.mapComponent.setFeaturePositionById(this.channelLayer, channel.gbId, {
|
||||
id: channel.gbId,
|
||||
position: [channel.gbLongitude, channel.gbLatitude],
|
||||
position: position,
|
||||
data: channel,
|
||||
image: {
|
||||
anchor: [0.5, 1],
|
||||
|
||||
Reference in New Issue
Block a user