methods: {
move(){
},
renderMap() {
var self = this;
var map = new AMap.Map("container", {
zoom: 16,
scrollWheel: false,
});
map.panTo([111.672046,40.821607])
AMapUI.loadUI(["misc/PositionPicker"], function (PositionPicker) {
if (self.point.length != 0) {
map.center = self.point;
}
var positionPicker = new PositionPicker({
mode: "dragMap", //Marker
map: map,//xy
iconStyle: {
//
url: require("../../../assets/images/@3x.png"), //
size: [22, 32], //
ancher: [24, 40] //size
}
});
positionPicker.on("success", function (positionResult) {
var location = {
address: positionResult.address,
point: [positionResult.position.lat, positionResult.position.lng]
};
self.address = location.address;
self.point=location.point;
self.$emit("location", location);
});
positionPicker.start();
map.panBy(0, 1);
if(self.po.point!==undefined){
var marker = new AMap.Marker({
position:[self.po.point[1],self.po.point[0]]
});
map.add(marker);//
}
});
}
}
vue2, wants to call the map.panTo method in renderMap () in the move method.
but I don"t know how to call it. I"ve tried a lot of methods, but I can"t use map.panto if I put it outside renderMap.
uses Amap"s API, but doesn"t know how to call his method outside.
Amap translate api
for a big solution, thank you very much.