From 1e7d96a0b08d74328ed7ae56fbd6a2d365eaadb5 Mon Sep 17 00:00:00 2001
From: jxdnsong <592566207@qq.com>
Date: Wed, 03 Feb 2021 16:39:32 +0800
Subject: [PATCH] 地图定位
---
src/views/realTimePolice/real.vue | 11 +++++++----
public/map/widgets/map/MapWidget.js | 8 ++------
public/map/index.html | 11 ++++++++---
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/public/map/index.html b/public/map/index.html
index 8edea66..d81d150 100644
--- a/public/map/index.html
+++ b/public/map/index.html
@@ -4,7 +4,7 @@
* @Author: yangsx
* @Date: 2019-11-28 09:50:16
* @LastEditors: song
- * @LastEditTime: 2021-02-01 17:14:21
+ * @LastEditTime: 2021-02-03 16:35:18
-->
<!DOCTYPE html>
<html lang="zh">
@@ -42,6 +42,7 @@
<script>
var _framework = null;
var _AppEvent = null;
+ var locationObj = null
function init(openId) {
if (openId && _AppEvent != null) {
@@ -55,6 +56,7 @@
_framework.onSiderContainerShow();
_framework.resize();
_AppEvent = AppEvent;
+ _AppEvent.addAppEventListener("mapLoad", mapLoad);
if (openId) showFun(openId);
}
);
@@ -64,9 +66,12 @@
_AppEvent.dispatchAppEvent(_AppEvent.RUN_WIDGET, id);
}
- function dw(x,y) {
- _AppEvent.dispatchAppEvent("goto", {x:x,y:y});
+ function mapLoad(map) {
+ if(locationObj) {
+ map.centerAndZoom(new esri.geometry.Point(locationObj.x,locationObj.y, new esri.SpatialReference({ wkid: 4326 })), 14);
+ }
}
+
</script>
</head>
diff --git a/public/map/widgets/map/MapWidget.js b/public/map/widgets/map/MapWidget.js
index 3b6a8d4..7de7685 100644
--- a/public/map/widgets/map/MapWidget.js
+++ b/public/map/widgets/map/MapWidget.js
@@ -124,10 +124,6 @@
this._eventHandlers.push(this.map.on("mouse-move", lang.hitch(this, this._onMouseMove)));
AppEvent.addAppEventListener(AppEvent.SWITCH_BASEMAP, lang.hitch(this, this.onSwitchBaseMap));
AppEvent.addAppEventListener(AppEvent.ADD_TOP_MOST_LAYER, lang.hitch(this, this.onAddTopMostLayer));
- AppEvent.addAppEventListener("goto", lang.hitch(this, this.goto));
- },
- goto: function (evt) {
- this.map.centerAndZoom(new Point(evt.x,evt.y, new SpatialReference({ wkid: 4326 })), 14);
},
onload: function () {
//var listNode = this.map.attribution.listNode;
@@ -245,7 +241,7 @@
}
}
}))
-
+ AppEvent.dispatchAppEvent("mapLoad", this.map);
return this.map
},
appendToolHandler: function (data) {
@@ -312,7 +308,7 @@
});
this.map.addLayer(cycleMap);
- this.map.centerAndZoom(new Point(115.806669,28.68635, new SpatialReference({ wkid: 4326 })), 14);
+ //this.map.centerAndZoom(new Point(115.806669,28.68635, new SpatialReference({ wkid: 4326 })), 14);
// //添加多时相图层
diff --git a/src/views/realTimePolice/real.vue b/src/views/realTimePolice/real.vue
index 6b17377..36f57b6 100644
--- a/src/views/realTimePolice/real.vue
+++ b/src/views/realTimePolice/real.vue
@@ -281,7 +281,8 @@
>
<iframe
id="mapDiv"
- src="https://s16s652780.51mypc.cn/jfpt/map/index.html"
+ ref="mapDiv"
+ src="/map/index.html"
frameborder="0"
width="100%"
height="100%"
@@ -776,9 +777,11 @@
},
handleMap(row) {
this.showMap = true;
- debugger;
- var sddsds = document.getElementById("mapDiv");
- document.getElementById("mapDiv").contentWindow.dw(row.jd,row.wd)
+ this.$nextTick(() => {
+ this.$refs.mapDiv.onload = () => {
+ window.frames[0].locationObj = {x:row.jd,y:row.wd};
+ };
+ })
},
handleManage(row) {
this.form = row;
--
Gitblit v1.9.3