diff --git a/packages/monitor/AppMonitorManage/AppMonitorManage.vue b/packages/monitor/AppMonitorManage/AppMonitorManage.vue index d983666c..4dbfe6ec 100644 --- a/packages/monitor/AppMonitorManage/AppMonitorManage.vue +++ b/packages/monitor/AppMonitorManage/AppMonitorManage.vue @@ -25,7 +25,7 @@ - + @@ -71,6 +71,7 @@ selected: { areaId: '' }, + latlng: null, disabledLevel: 0, rules: { name: [{required: true, message: "请填写 设备名称"}] @@ -155,6 +156,10 @@ } else if (command == "area") {//绑定areaId this.$refs.BindArea?.chooseArea() } else if (command == "locate") {//地图标绘 + this.latlng = data.lat && data.lng ? { + lat: data.lat, + lng: data.lng + } : '' this.locate = true } }, diff --git a/packages/monitor/components/locateDialog.vue b/packages/monitor/components/locateDialog.vue index 13cdd466..a8af27a3 100644 --- a/packages/monitor/components/locateDialog.vue +++ b/packages/monitor/components/locateDialog.vue @@ -30,9 +30,7 @@ export default { prop: "visible", event: "visible", }, - props: { - visible: Boolean - }, + props: ['latlng', 'visible'], data() { return { dialog: false, @@ -57,13 +55,21 @@ export default { plugins: ['AMap.PlaceSearch', 'AMap.Marker', 'AMap.Geolocation'], }).then(AMap => { this.AMap = AMap + console.log(this.latlng) this.map = new AMap.Map('amap', { zoom: 14, + center: this.latlng ? [this.latlng.lng, this.latlng.lat] : '' }).on('click', res => { this.map.clearMap() this.selected = {location: res.lnglat} this.poi?.searchNearBy('', res.lnglat, 100) }); + if (this.latlng) { + let marker = new AMap.Marker({ + position: [this.latlng.lng, this.latlng.lat] + }) + this.map.add(marker) + } this.poi = new AMap.PlaceSearch().on('complete', ({poiList}) => { this.map.clearMap() if (poiList?.length > 0) {