gjy 3 years ago
parent
commit
34fc5d1333

+ 1 - 1
src/components/mapdrag/indexMap.vue

@@ -160,7 +160,7 @@
         AMapLoader.load({
         AMapLoader.load({
           "key": "211dd6f989e719022aaf47ddb0659c47", // 申请好的Web端开发者Key,首次调用 load 时必填
           "key": "211dd6f989e719022aaf47ddb0659c47", // 申请好的Web端开发者Key,首次调用 load 时必填
           "version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
           "version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
-          "plugins": ['plugin=AMap.Scale', 'AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Geocoder', 'AMap.DistrictSearch'],
+          "plugins": ['plugin=AMap.Scale', 'AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Geocoder', 'AMap.DistrictSearch','AMap.Geolocation', 'Geolocation'],
           "Loca": { // 是否加载 Loca, 缺省不加载
           "Loca": { // 是否加载 Loca, 缺省不加载
             "version": '2.0.0' // Loca 版本,缺省 1.3.2
             "version": '2.0.0' // Loca 版本,缺省 1.3.2
           },
           },

+ 1 - 1
src/components/mapdrag/mapdrag.vue

@@ -184,7 +184,7 @@
         AMapLoader.load({
         AMapLoader.load({
           "key": "211dd6f989e719022aaf47ddb0659c47", // 申请好的Web端开发者Key,首次调用 load 时必填
           "key": "211dd6f989e719022aaf47ddb0659c47", // 申请好的Web端开发者Key,首次调用 load 时必填
           "version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
           "version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
-          "plugins": ['plugin=AMap.Scale', 'AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Geocoder', 'AMap.DistrictSearch'],
+          "plugins": ['plugin=AMap.Scale', 'AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Geocoder', 'AMap.DistrictSearch','AMap.Geolocation', 'Geolocation'],
           "Loca": { // 是否加载 Loca, 缺省不加载
           "Loca": { // 是否加载 Loca, 缺省不加载
             "version": '2.0.0' // Loca 版本,缺省 1.3.2
             "version": '2.0.0' // Loca 版本,缺省 1.3.2
           },
           },

+ 15 - 8
src/components/mapdrag/warehouseReceiptMap.vue

@@ -60,6 +60,7 @@
       listData: function(val1, val2) {
       listData: function(val1, val2) {
         this.listData = val1
         this.listData = val1
         var that = this
         var that = this
+        
         this.map = new AMap.Map('mapContainer', {
         this.map = new AMap.Map('mapContainer', {
           resizeEnable: true,
           resizeEnable: true,
           zoom: 5,
           zoom: 5,
@@ -72,14 +73,21 @@
     },
     },
     async created() {
     async created() {
       // AMapLoader.reset();
       // AMapLoader.reset();
-      // 已载入高德地图API,则直接初始化地图
       if (window.AMap && window.AMapUI) {
       if (window.AMap && window.AMapUI) {
-        this.initMap()
         // 未载入高德地图API,则先载入API再初始化
         // 未载入高德地图API,则先载入API再初始化
       } else {
       } else {
-        await remoteLoad(`http://webapi.amap.com/maps?v=1.3&key=${MapKey}&plugin=AMap.AutoComplete`)
-        await remoteLoad('http://webapi.amap.com/ui/1.0/main.js')
-        this.initMap()
+        // await remoteLoad(`http://webapi.amap.com/maps?v=1.3&key=${MapKey}&plugin=AMap.AutoComplete`)
+        // await remoteLoad('http://webapi.amap.com/ui/1.0/main.js')
+        //  AMapLoader.reset();
+        AMapLoader.load({
+          "key": "211dd6f989e719022aaf47ddb0659c47", // 申请好的Web端开发者Key,首次调用 load 时必填
+          "version": "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
+          "plugins": ['plugin=AMap.Scale', 'AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Geocoder', 'AMap.DistrictSearch','AMap.Geolocation', 'Geolocation'],
+          "Loca": { // 是否加载 Loca, 缺省不加载
+            "version": '2.0.0' // Loca 版本,缺省 1.3.2
+          },
+        }).then((AMap) => {
+        })
       }
       }
     },
     },
     mounted() {},
     mounted() {},
@@ -95,7 +103,6 @@
       loadmap(val) {
       loadmap(val) {
         let that = this
         let that = this
         //构造markersList
         //构造markersList
-        this.makeMarkersList()
         AMap.plugin(['AMap.DistrictSearch', 'AMap.Polygon'], function() {
         AMap.plugin(['AMap.DistrictSearch', 'AMap.Polygon'], function() {
           var geolocation = new AMap.Geolocation({
           var geolocation = new AMap.Geolocation({
             // 是否使用高精度定位,默认:true
             // 是否使用高精度定位,默认:true
@@ -106,7 +113,7 @@
             buttonPosition: 'RB'
             buttonPosition: 'RB'
           })
           })
           geolocation.getCurrentPosition()
           geolocation.getCurrentPosition()
-          AMap.event.addListener(geolocation, 'complete', e => {
+          geolocation.on( 'complete', e => {
             console.log(e) // 定位成功之后做的事 // 定位成功之后再定位处添加一个marker
             console.log(e) // 定位成功之后做的事 // 定位成功之后再定位处添加一个marker
             var infoWindow = new AMap.InfoWindow({
             var infoWindow = new AMap.InfoWindow({
               offset: new AMap.Pixel(0, -30)
               offset: new AMap.Pixel(0, -30)
@@ -166,7 +173,7 @@
               // });
               // });
             }
             }
           })
           })
-          AMap.event.addListener(geolocation, 'error', e => {
+           geolocation.on( 'error', e => {
             console.log(e) // 定位失败
             console.log(e) // 定位失败
           })
           })
         })
         })