Commit 0212b640 by 前端

修复bug

1 parent 77dc9a43
...@@ -250,6 +250,7 @@ export default { ...@@ -250,6 +250,7 @@ export default {
_this.mapLoading = false; _this.mapLoading = false;
window.AMap = AMap; window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 12 }); _this.map = mapService.init("map", { zoom: 12 });
_this.mouseTool = new AMap.MouseTool(_this.map);
var autoComplete = new AMap.AutoComplete({ var autoComplete = new AMap.AutoComplete({
input: "tipInput", input: "tipInput",
}); });
...@@ -257,7 +258,7 @@ export default { ...@@ -257,7 +258,7 @@ export default {
console.log(e); console.log(e);
let poi = e.poi || {}; let poi = e.poi || {};
_this.poi = poi; _this.poi = poi;
_this.$refs.addressInput.focus() _this.$refs.addressInput.focus();
}); });
}) })
.catch((error) => { .catch((error) => {
...@@ -270,7 +271,7 @@ export default { ...@@ -270,7 +271,7 @@ export default {
getAddress() { getAddress() {
let _this = this; let _this = this;
let poi = this.poi; let poi = this.poi;
_this.clearMap() _this.clearMap();
if (poi && poi.location) { if (poi && poi.location) {
_this.autoCenterMarker = mapService.createMarker(poi.location); _this.autoCenterMarker = mapService.createMarker(poi.location);
_this.map.setFitView(); _this.map.setFitView();
...@@ -289,18 +290,17 @@ export default { ...@@ -289,18 +290,17 @@ export default {
}); });
return false; return false;
} }
// if (_this.mouseTool) {
if (_this.mouseTool) { // _this.mouseTool.close();
return false; // return false;
} // }
console.log(_zoom);
if (_zoom < 14) { if (_zoom < 14) {
_this.map.setZoom(14); _this.map.setZoom(14);
} }
_this.map.setZooms([14, 30]); _this.map.setZooms([14, 30]);
var mouseTool = new AMap.MouseTool(_map);
mouseTool.rectangle({ if (_this.mouseTool) {
_this.mouseTool.rectangle({
fillColor: "#2C68FF", fillColor: "#2C68FF",
strokeColor: "#2C68FF", strokeColor: "#2C68FF",
fillOpacity: 0.3, fillOpacity: 0.3,
...@@ -308,14 +308,13 @@ export default { ...@@ -308,14 +308,13 @@ export default {
strokeOpacity: 1, strokeOpacity: 1,
draggable: true, draggable: true,
}); });
mouseTool.close() _this.mouseTool.on("draw", function (e) {
mouseTool.on("draw", function (e) {
let rectangle = e.obj; let rectangle = e.obj;
mouseTool.close(); _this.mouseTool.close();
_this.rectangle = rectangle; _this.rectangle = rectangle;
_this.calculateWidthHeight(rectangle.getOptions().bounds); _this.calculateWidthHeight(rectangle.getOptions().bounds);
}); });
_this.mouseTool = mouseTool; }
}, },
// 计算矩形宽度、高度 // 计算矩形宽度、高度
...@@ -351,7 +350,7 @@ export default { ...@@ -351,7 +350,7 @@ export default {
this.rectangleHeight = 0; this.rectangleHeight = 0;
this.rectangleWidth = 0; this.rectangleWidth = 0;
this.rectangle = null; this.rectangle = null;
this.mouseTool = null; //this.mouseTool = null;
this.deviceList = []; this.deviceList = [];
this.map.setZooms([2, 30]); this.map.setZooms([2, 30]);
}, },
...@@ -363,7 +362,10 @@ export default { ...@@ -363,7 +362,10 @@ export default {
this.rectangleWidth = 0; this.rectangleWidth = 0;
this.form = {}; this.form = {};
this.deviceList = []; this.deviceList = [];
this.mouseTool = null; if (this.mouseTool) {
this.mouseTool.close(true);
//this.mouseTool = null;
}
}, },
// 展开 // 展开
...@@ -486,7 +488,7 @@ export default { ...@@ -486,7 +488,7 @@ export default {
GER_REGIONAL_LOCATION(params).then((res) => { GER_REGIONAL_LOCATION(params).then((res) => {
let list = res.data || []; let list = res.data || [];
if(res.code != 200){ if (res.code != 200) {
showToast({ showToast({
message: res.message, message: res.message,
}); });
...@@ -631,7 +633,9 @@ export default { ...@@ -631,7 +633,9 @@ export default {
}); });
mass.setMap(_this.map); mass.setMap(_this.map);
this.drawDone = true; this.drawDone = true;
//this.map.setFitView(); if(arr && arr.length<10){
this.map.setFitView();
}
this.mapMass = mass; this.mapMass = mass;
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!