Commit 60e602e6 authored by yaqizhang's avatar yaqizhang

6666666

parent 8243d948
......@@ -41,7 +41,7 @@ class gaodeMap {
leftListClick = false;
//构造函数中设置中央点默认值
constructor(center) {
constructor(center, latlng) {
this.markers = [];
this.center = center ? center : defaultCenter;
map = new AMap.Map("container", {
......@@ -77,7 +77,7 @@ class gaodeMap {
this.createNewLine();
console.log("map点击事件新建");
})
.catch(() => {});
.catch(() => { });
}
// console.log("抬起来了");
});
......@@ -116,9 +116,10 @@ class gaodeMap {
let options = this.myMap.getStatus();
options.scrollWheel = true;
this.myMap.setStatus(options);
console.log("飞行结束")
});
this.districtBoundaries();
this.districtBoundaries(latlng);
}
panTo(lnglat) {
this.myMap.panTo(lnglat);
......@@ -148,7 +149,7 @@ class gaodeMap {
* 设置城市边界
*/
districtBoundaries() {
districtBoundaries(latlng) {
let that = this;
let opts = {
subdistrict: 0,
......@@ -156,12 +157,20 @@ class gaodeMap {
level: "city"
};
let district = new AMap.DistrictSearch(opts);
district.search(that.center, function(status, result) {
district.search(that.center, function (status, result) {
if (status == "complete") {
let defaultCenter = [];
defaultCenter.push(result.districtList[0].center.lng);
defaultCenter.push(result.districtList[0].center.lat);
map.setCenter(defaultCenter);
if (latlng) {
map.setCenter(latlng);
} else {
map.setCenter(defaultCenter);
}
console.log("defaultCenter", defaultCenter)
let bounds = result.districtList[0].boundaries;
for (let i = 0; i < bounds.length; i += 1) {
new AMap.Polyline({
......@@ -190,12 +199,12 @@ class gaodeMap {
offset: new AMap.Pixel(24, -38),
anchor: "left-top"
});
infoWindow.on("mouseover", function() {
infoWindow.on("mouseover", function () {
let options = map.getStatus();
options.scrollWheel = false;
map.setStatus(options);
});
infoWindow.on("mouseout", function() {
infoWindow.on("mouseout", function () {
let options = map.getStatus();
options.scrollWheel = true;
map.setStatus(options);
......@@ -225,7 +234,7 @@ class gaodeMap {
editWindow.obj = marker;
editWindow.gaoMap = that;
editWindow.map = map;
marker.on("click", function(e) {
marker.on("click", function (e) {
if ("edit" == that.mapOperateType) {
editWindow.form = e.target.getExtData();
editWindow.show();
......@@ -239,10 +248,10 @@ class gaodeMap {
vue
.$confirm(
'是否删除名称为"' +
e.target.getExtData().deviceName +
'"的' +
diviceType[markerType] +
" ?",
e.target.getExtData().deviceName +
'"的' +
diviceType[markerType] +
" ?",
"提示",
{
type: "warning"
......@@ -287,19 +296,19 @@ class gaodeMap {
infoWindow.open(map, e.target.getPosition());
}*/
});
marker.on("dragend", function(e) {
marker.on("dragend", function (e) {
editWindow.form.longitude = e.lnglat.lng;
editWindow.form.latitude = e.lnglat.lat;
});
} else {
marker.on("mouseover", function() {
marker.on("mouseover", function () {
marker.setLabel({
offset: new AMap.Pixel(0, -10), //设置文本标注偏移量
content: "<div class='info'>" + data.deviceName + "</div>", //设置文本标注内容
direction: "top" //设置文本标注方位
});
});
marker.on("mouseout", function() {
marker.on("mouseout", function () {
marker.setLabel({
content: null
});
......@@ -943,14 +952,14 @@ class gaodeMap {
this.overlays = [];
let that = this;
this.markerOverlays = [];
this.mouseTool.on("draw", function(e) {
this.mouseTool.on("draw", function (e) {
if (e.obj.getExtData().type != "newLine") {
map.remove(that.markerOverlays);
const device = that.createInfowindow("新增");
device.map = map;
device.obj = e.obj;
device.gaoMap = that;
e.obj.on("click", function(aa) {
e.obj.on("click", function (aa) {
let postion = aa.target._position;
//兼容拖拽后单击事件,拖拽后点击事件返回位置为数组
if (postion instanceof Array) {
......@@ -962,11 +971,11 @@ class gaodeMap {
}
device.show();
});
e.obj.on("mouseover", function() {
e.obj.on("mouseover", function () {
that.mouseTool.close();
});
e.obj.on("mouseout", function() {
e.obj.on("mouseout", function () {
that.draw(that.deviceType);
});
......@@ -1077,7 +1086,7 @@ class gaodeMap {
"AMap.MapType",
"AMap.Geolocation"
],
function() {
function () {
// 在图面添加工具条控件,工具条控件集成了缩放、平移、定位等功能按钮在内的组合控件
//map.addControl(new AMap.ToolBar());
......@@ -1100,7 +1109,7 @@ class gaodeMap {
searchTips(inputId) {
let that = this;
AMap.plugin(["AMap.AutoComplete", "AMap.PlaceSearch"], function() {
AMap.plugin(["AMap.AutoComplete", "AMap.PlaceSearch"], function () {
//输入提示
// var autoOptions = {
// input: inputId
......
......@@ -215,8 +215,8 @@
// this.getData();
},
mounted() {
let gaoMap = new gaodeMap("石家庄");
this.gaoMap = gaoMap;
// let gaoMap = new gaodeMap("石家庄");
// this.gaoMap = gaoMap;
this.getData();
},
methods: {
......@@ -585,10 +585,10 @@
this.dataListdetail3.push(obj3);
this.form = response.data;
this.active = parseInt(response.data.orderStatus) + 1;
this.gaoMap.addMarker(DEVICE_TYPE.WORKORDER, this.form,()=>{
this.gaoMap.panTo([this.form.longitude, this.form.latitude]);
})
let gaoMap = new gaodeMap("石家庄",[this.form.longitude, this.form.latitude]);
this.gaoMap = gaoMap;
this.gaoMap.addMarker(DEVICE_TYPE.WORKORDER, this.form)
// this.gaoMap.resetMapCenter([this.form.longitude, this.form.latitude]);
console.log("this.form.longitude",this.form.longitude)
console.log("this.form", this.form)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment