|
@@ -60,6 +60,7 @@
|
|
|
listData: function(val1, val2) {
|
|
|
this.listData = val1
|
|
|
var that = this
|
|
|
+
|
|
|
this.map = new AMap.Map('mapContainer', {
|
|
|
resizeEnable: true,
|
|
|
zoom: 5,
|
|
@@ -72,14 +73,21 @@
|
|
|
},
|
|
|
async created() {
|
|
|
// AMapLoader.reset();
|
|
|
- // 已载入高德地图API,则直接初始化地图
|
|
|
if (window.AMap && window.AMapUI) {
|
|
|
- this.initMap()
|
|
|
// 未载入高德地图API,则先载入API再初始化
|
|
|
} 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() {},
|
|
@@ -95,7 +103,6 @@
|
|
|
loadmap(val) {
|
|
|
let that = this
|
|
|
//构造markersList
|
|
|
- this.makeMarkersList()
|
|
|
AMap.plugin(['AMap.DistrictSearch', 'AMap.Polygon'], function() {
|
|
|
var geolocation = new AMap.Geolocation({
|
|
|
// 是否使用高精度定位,默认:true
|
|
@@ -106,7 +113,7 @@
|
|
|
buttonPosition: 'RB'
|
|
|
})
|
|
|
geolocation.getCurrentPosition()
|
|
|
- AMap.event.addListener(geolocation, 'complete', e => {
|
|
|
+ geolocation.on( 'complete', e => {
|
|
|
console.log(e) // 定位成功之后做的事 // 定位成功之后再定位处添加一个marker
|
|
|
var infoWindow = new AMap.InfoWindow({
|
|
|
offset: new AMap.Pixel(0, -30)
|
|
@@ -166,7 +173,7 @@
|
|
|
// });
|
|
|
}
|
|
|
})
|
|
|
- AMap.event.addListener(geolocation, 'error', e => {
|
|
|
+ geolocation.on( 'error', e => {
|
|
|
console.log(e) // 定位失败
|
|
|
})
|
|
|
})
|