|
|
|
@ -98,7 +98,6 @@ export default { |
|
|
|
|
// immediate: true, |
|
|
|
|
deep: true, |
|
|
|
|
handler(val,oval) { |
|
|
|
|
console.log(val,oval) |
|
|
|
|
if (val&&val.every((v, i) => v !== oval[i])) { |
|
|
|
|
this.initMap(val) |
|
|
|
|
} |
|
|
|
@ -138,13 +137,11 @@ export default { |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
initMap(center) { |
|
|
|
|
console.log(center, '点位中心') |
|
|
|
|
this.map = new window.AMap.Map(this.$refs.mapContainer, { |
|
|
|
|
center: center[0] == undefined ? this.mapCente : center, |
|
|
|
|
plugins: ['AMap.AutoComplete'], |
|
|
|
|
zoom: 13 |
|
|
|
|
}) |
|
|
|
|
console.log(this.pointArr, '00000') |
|
|
|
|
if (center[0] != undefined) { |
|
|
|
|
this.marker = new AMap.Marker({ |
|
|
|
|
icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", |
|
|
|
@ -154,6 +151,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
if (this.pointArr && this.pointArr.length > 0) { |
|
|
|
|
this.addMarker(this.pointArr) |
|
|
|
|
console.log(this.pointArr) |
|
|
|
|
this.map.setFitView() |
|
|
|
|
} |
|
|
|
|
if (this.pathArr !== undefined && this.pathArr.length > 1) { |
|
|
|
@ -163,7 +161,6 @@ export default { |
|
|
|
|
this.map.setFitView() |
|
|
|
|
}, |
|
|
|
|
addMarker(position) { // 添加标记点 |
|
|
|
|
console.log(position, '打点数组') |
|
|
|
|
let this_ = this |
|
|
|
|
// if (position !== undefined && position.length <= 2 || Array.isArray(position) === false && Object.keys(position).length > 0) { |
|
|
|
|
if (position && Array.isArray(position) === false) { |
|
|
|
@ -177,7 +174,6 @@ export default { |
|
|
|
|
this.markers.push(this_.marker) |
|
|
|
|
this.selectedMarker = this_.marker // s更新当前选中的标记点 |
|
|
|
|
} else { |
|
|
|
|
console.log(position, '这里是获取到的陆游线路点位') |
|
|
|
|
position.forEach(item => { |
|
|
|
|
this_.marker = new window.AMap.Marker({ |
|
|
|
|
position: [item.lon, item.lat] |
|
|
|
@ -238,7 +234,6 @@ export default { |
|
|
|
|
} |
|
|
|
|
const placeSearch = new AMap.PlaceSearch(autoOptions) |
|
|
|
|
placeSearch.search(addr, function (status, result) { |
|
|
|
|
console.log(status, result, '搜索结果') |
|
|
|
|
|
|
|
|
|
if (result.info == 'OK') { |
|
|
|
|
this_.map.setCenter([result.poiList.pois[0].location.lng, result.poiList.pois[0].location.lat]) |
|
|
|
|