From 1a161393ef707272bcd534c7cfffd7ea0e60b866 Mon Sep 17 00:00:00 2001
From: jxdnsong <592566207@qq.com>
Date: Sat, 27 Feb 2021 15:54:44 +0800
Subject: [PATCH] 实时报警定位功能完善

---
 public/map/index.html |   38 ++++++++++++++------------------------
 1 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/public/map/index.html b/public/map/index.html
index cb5f408..b246857 100644
--- a/public/map/index.html
+++ b/public/map/index.html
@@ -34,13 +34,12 @@
   <script>
     var _framework = null;
     var _AppEvent = null;
-    var locationObj = null
 
-    function init(openId) {
-      if (openId && _AppEvent != null) {
-        showFun(openId);
-        return;
-      }
+    function getQueryStringByKey(key) {
+      return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
+    }
+
+    function init(openId,locationObj) {
       $.divselect("#divselect", "#inputselect");
       require(["base/framework", "base/AppEvent"],
         function (framework, AppEvent) {
@@ -48,7 +47,14 @@
           _framework.onSiderContainerShow();
           _framework.resize();
           _AppEvent = AppEvent;
-          _AppEvent.addAppEventListener("mapLoad", mapLoad);
+          
+          _AppEvent.addAppEventListener("mapLoad", function(map){
+            if (locationObj && locationObj != null) {
+              map.centerAndZoom(new esri.geometry.Point(locationObj.x,locationObj.y, new esri.SpatialReference({ wkid: 4326 })), 14);
+            }
+          });
+          
+          var openId = getQueryStringByKey('openid');
           if (openId) showFun(openId);
         }
       );
@@ -58,16 +64,11 @@
       _AppEvent.dispatchAppEvent(_AppEvent.RUN_WIDGET, id);
     }
 
-    function mapLoad(map) {
-      // if(locationObj) {
-      //   map.centerAndZoom(new esri.geometry.Point(locationObj.x,locationObj.y, new esri.SpatialReference({ wkid: 4326 })), 14);
-      // }
-    }
 
   </script>
 </head>
 
-<body onload="init()">
+<body>
 
   <div class="map_content">
 
@@ -99,16 +100,5 @@
 </body>
 <script src="./js/monitor.js"></script>
 <script src="./js/forestry-map.js"></script>
-
-<script>
-  var openId = getQueryStringByKey('openid');
-  if (openId && openId != '') {
-    init(openId)
-  }
-
-  function getQueryStringByKey(key) {
-    return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
-  }
-</script>
 
 </html>

--
Gitblit v1.9.3