initMapWeb() {
let that = this;
this.map = new AMap.Map("map", {
center: this.initLocation && this.initLocation.split(','),
zoom: 16
});
this.map.on('click', (e) => {
if (this.marker) {
this.marker.setMap(null);
}
that.addMarker(e.lnglat.lng, e.lnglat.lat);
that.getPlaces('', `${e.lnglat.lng}, ${e.lnglat.lat}`);
that.getNowPlace(`${e.lnglat.lng}, ${e.lnglat.lat}`);
})
if (this.initLocation.length > 0) {
let tempArr = this.initLocation.split(',');
that.addMarker(tempArr[0], tempArr[1])
that.getPlaces('', `${tempArr[0]}, ${tempArr[1]}`);
that.getNowPlace(`${tempArr[0]}, ${tempArr[1]}`);
return
}
AMap.plugin('AMap.Geolocation', function () {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000,
maximumAge: 0, // 定位结果缓存有效期,默认:0(不使用缓存)
convert: false, // 自动偏移坐标,默认:false
showButton: true, // 显示定位按钮,默认:false
// 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
buttonOffset: new AMap.Pixel(10, 20),
// 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
zoomToAccuracy: true,
// 定位按钮的排放位置, RB表示右下
buttonPosition: 'RB'
})
geolocation.getCurrentPosition(function (status, result) {
if (result.info == "SUCCESS" && result.position && result.position) {
that.addMarker(result.position.lng, result.position.lat)
that.getPlaces('', `${result.position.lng}, ${result.position.lat}`)
that.getNowPlace(`${result.position.lng}, ${result.position.lat}`);
}
});
})
},
this.map.on('click', (e) => {
if (this.marker) {
this.marker.setMap(null);
}
that.addMarker(e.lnglat.lng, e.lnglat.lat);
that.getPlaces('', ${e.lnglat.lng}, ${e.lnglat.lat});
that.getNowPlace(${e.lnglat.lng}, ${e.lnglat.lat});
}) 这个click事件在ios浏览器上默认不执行,有没有解决方法
0 个回复