|
|
@@ -6,8 +6,10 @@
|
|
|
<div slot="header" class="clearfix">
|
|
|
<el-select
|
|
|
v-model="selectedOption"
|
|
|
+ clearable
|
|
|
placeholder="选择标签"
|
|
|
- @change="onChange"
|
|
|
+ style="padding-right: 3px"
|
|
|
+ @change="onSelectChange"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="(item, index) in selectOptions"
|
|
|
@@ -16,7 +18,18 @@
|
|
|
:value="item.value"
|
|
|
/>
|
|
|
</el-select>
|
|
|
- <el-button style="float: right; padding: 3px 0" type="text" @click="onRefresh">刷新</el-button>
|
|
|
+ <el-cascader
|
|
|
+ v-model="cascaderOption"
|
|
|
+ :options="cascaderOptions"
|
|
|
+ :props="{ checkStrictly: true }"
|
|
|
+ placeholder="或者选择地区(支持地区搜索)"
|
|
|
+ style="padding-right: 3px"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ @change="onCascaderChange"
|
|
|
+ />
|
|
|
+ <el-button style="float: right; padding-right: 5px" type="text" @click="onRefreshButton">刷新</el-button>
|
|
|
+ <el-button style="float: right; padding-right: 5px" type="text" @click="onNearbyButton">我的附近</el-button>
|
|
|
</div>
|
|
|
<div class="text item amap-wrapper">
|
|
|
<el-amap
|
|
|
@@ -94,7 +107,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getPhotoItems, getPhotoMarks, getMarkerInfo } from '@/api/map'
|
|
|
+import {
|
|
|
+ getPhotoItems,
|
|
|
+ getPhotoMarks,
|
|
|
+ getMarkerInfo,
|
|
|
+ getAreaCascadeOptions,
|
|
|
+ getPhotoMarksArea,
|
|
|
+ getPhotoMarksNearby
|
|
|
+} from '@/api/map'
|
|
|
|
|
|
import Vue from 'vue'
|
|
|
import VueAMap from 'vue-amap'
|
|
|
@@ -141,8 +161,8 @@ export default {
|
|
|
massMarks: null,
|
|
|
amapManager,
|
|
|
mapEvents: {
|
|
|
- init: this.mapInit,
|
|
|
- zoomchange: this.zoomchange
|
|
|
+ init: this.mapInitEvent,
|
|
|
+ zoomchange: this.zoomChangeEvent
|
|
|
},
|
|
|
/* 弹框数据 */
|
|
|
showMarkerDialog: false,
|
|
|
@@ -158,16 +178,25 @@ export default {
|
|
|
lat: null,
|
|
|
lng: null
|
|
|
},
|
|
|
- selectedOption: 1,
|
|
|
+ selectedOption: '',
|
|
|
selectOptions: [],
|
|
|
- value: []
|
|
|
+ cascaderOption: [],
|
|
|
+ cascaderOptions: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
document.title = '照片地图'
|
|
|
+ this.getData()
|
|
|
this.getItems()
|
|
|
},
|
|
|
methods: {
|
|
|
+ getData() {
|
|
|
+ getAreaCascadeOptions().then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.cascaderOptions = resp.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
getItems() {
|
|
|
getPhotoItems().then(resp => {
|
|
|
if (resp.code === 0) {
|
|
|
@@ -175,7 +204,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- mapInit(o) {
|
|
|
+ mapInitEvent(o) {
|
|
|
this.amap = o
|
|
|
lazyAMapApiLoaderInstance.load().then(() => {
|
|
|
// 图标样式
|
|
|
@@ -200,23 +229,25 @@ export default {
|
|
|
})
|
|
|
this.massMarks = massMarks
|
|
|
|
|
|
- this.getPhotoMarksWrapper(this.selectedOption)
|
|
|
+ if (this.selectedOption !== '') {
|
|
|
+ this.getPhotoMarksWrapper(this.selectedOption)
|
|
|
+ }
|
|
|
// this.getPhotoMarksWrapper1(type)
|
|
|
})
|
|
|
},
|
|
|
- zoomchange(e) {
|
|
|
+ zoomChangeEvent(e) {
|
|
|
console.log('当前缩放级别: ' + this.amap.getZoom())
|
|
|
},
|
|
|
getPhotoMarksWrapper(type) {
|
|
|
- this.markers = []
|
|
|
getPhotoMarks(type).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
this.$notify({
|
|
|
message: '加载了 ' + res.data.length + ' 条数据',
|
|
|
type: 'warning',
|
|
|
- duration: 5000
|
|
|
+ duration: 1000
|
|
|
})
|
|
|
|
|
|
+ this.markers = []
|
|
|
for (const item of res.data) {
|
|
|
this.markers.push({
|
|
|
position: [item.position.lng, item.position.lat],
|
|
|
@@ -247,9 +278,10 @@ export default {
|
|
|
this.$notify({
|
|
|
message: '加载了 ' + res.data.length + ' 条数据',
|
|
|
type: 'warning',
|
|
|
- duration: 5000
|
|
|
+ duration: 1000
|
|
|
})
|
|
|
|
|
|
+ this.markers = []
|
|
|
const massMarkers = []
|
|
|
for (const item of res.data) {
|
|
|
massMarkers.push({
|
|
|
@@ -297,7 +329,107 @@ export default {
|
|
|
console.log(error)
|
|
|
})
|
|
|
},
|
|
|
- /* 弹出框 */
|
|
|
+ onSelectChange() {
|
|
|
+ this.cascaderOption = []
|
|
|
+ if (this.selectedOption === '') {
|
|
|
+ this.$message.error('请先选择标签')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getPhotoMarksWrapper(this.selectedOption)
|
|
|
+ },
|
|
|
+ onCascaderChange(val) {
|
|
|
+ this.selectedOption = ''
|
|
|
+ const length = val.length
|
|
|
+ if (length === 0) {
|
|
|
+ this.$message.error('请先选择地区')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var areaCode = this.cascaderOption[length - 1]
|
|
|
+ getPhotoMarksArea(areaCode).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$notify({
|
|
|
+ message: '加载了 ' + res.data.length + ' 条数据',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+
|
|
|
+ this.markers = []
|
|
|
+ for (const item of res.data) {
|
|
|
+ this.markers.push({
|
|
|
+ position: [item.position.lng, item.position.lat],
|
|
|
+ label: { content: item.title, offset: [0, 0] },
|
|
|
+ extData: { id: item.id }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ message: error.message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onRefreshButton() {
|
|
|
+ if (this.cascaderOption.length !== 0) {
|
|
|
+ this.onCascaderChange(this.cascaderOption)
|
|
|
+ } else if (this.selectedOption !== '') {
|
|
|
+ this.getPhotoMarksWrapper(this.selectedOption)
|
|
|
+ } else {
|
|
|
+ this.$message.error('请先选择标签或地区后再刷新')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onNearbyButton() {
|
|
|
+ // 5km
|
|
|
+ var distance = 5000
|
|
|
+ getPhotoMarksNearby(distance).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$notify({
|
|
|
+ message: '加载了 ' + res.data.length + ' 条数据',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+
|
|
|
+ var myMark = res.data[res.data.length - 1]
|
|
|
+ this.mapCenter = [myMark.position.lng, myMark.position.lat]
|
|
|
+ // 比例尺 1000m
|
|
|
+ this.zoom = 13
|
|
|
+ this.amap.setCenter(this.mapCenter)
|
|
|
+ this.amap.setZoom(this.zoom)
|
|
|
+
|
|
|
+ this.markers = []
|
|
|
+ for (const item of res.data) {
|
|
|
+ this.markers.push({
|
|
|
+ position: [item.position.lng, item.position.lat],
|
|
|
+ label: { content: item.title, offset: [0, 0] },
|
|
|
+ extData: { id: item.id }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ message: error.message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // *************************************************************
|
|
|
+ // 弹出框
|
|
|
handleDialogClose(done) {
|
|
|
this.showMarkerDialog = false
|
|
|
this.earthPoint = { lat: null, lng: null }
|
|
|
@@ -316,12 +448,6 @@ export default {
|
|
|
type: 'error',
|
|
|
duration: 1000
|
|
|
})
|
|
|
- },
|
|
|
- onChange() {
|
|
|
- this.getPhotoMarksWrapper(this.selectedOption)
|
|
|
- },
|
|
|
- onRefresh() {
|
|
|
- this.getPhotoMarksWrapper(this.selectedOption)
|
|
|
}
|
|
|
}
|
|
|
}
|