|
@@ -4,7 +4,7 @@
|
|
|
margin-top: 64px;
|
|
|
}
|
|
|
#mapContainer {
|
|
|
- width: 300px;
|
|
|
+ width: 750px;
|
|
|
height: 300px;
|
|
|
}
|
|
|
#tip {
|
|
@@ -83,6 +83,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { regionData, CodeToText, TextToCode } from 'element-china-area-data'
|
|
|
import image from '../../../public/img/ic_locationmarker.jpg'
|
|
|
export default {
|
|
|
data() {
|
|
@@ -95,6 +96,7 @@ export default {
|
|
|
citys: [],
|
|
|
city: '',
|
|
|
polygons: [],
|
|
|
+ selectedOptions1:[],
|
|
|
areacode: '',
|
|
|
address: '',
|
|
|
objPoint: [],
|
|
@@ -104,12 +106,26 @@ export default {
|
|
|
status: true,
|
|
|
}
|
|
|
},
|
|
|
- props: ['flagVisible', 'position'],
|
|
|
+ props: ['flagVisible', 'position','selectedOptions'],
|
|
|
computed: {
|
|
|
showFlag() {
|
|
|
return this.flagVisible
|
|
|
},
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ selectedOptions:{
|
|
|
+ handler(newValue, oldValue) {
|
|
|
+ console.log(CodeToText[newValue[1]])
|
|
|
+ this.province=newValue[0]
|
|
|
+ this.selectP(this.province)
|
|
|
+ this.city = CodeToText[newValue[1]]
|
|
|
+ this.selectC(CodeToText[newValue[1]])
|
|
|
+ this.district= newValue[2]
|
|
|
+ this.selectD(this.district)
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
+ },
|
|
|
async created() {
|
|
|
// 已载入高德地图API,则直接初始化地图
|
|
|
if (window.AMap && window.AMapUI) {
|
|
@@ -122,6 +138,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ // console.log(this)
|
|
|
setTimeout(() => {
|
|
|
var that = this
|
|
|
this.map = new AMap.Map('mapContainer', {
|
|
@@ -270,6 +287,7 @@ export default {
|
|
|
}
|
|
|
var district = new AMap.DistrictSearch(opts) // 注意:需要使用插件同步下发功能才能这样直接使用
|
|
|
function getData(data) {
|
|
|
+ console.log(data)
|
|
|
that.$emit('selectedAddress', data)
|
|
|
// 清除地图上的所有覆盖物
|
|
|
that.areacode = data.citycode
|
|
@@ -306,19 +324,21 @@ export default {
|
|
|
let sear = val ? params : '中国'
|
|
|
district.search(sear, function (status, result) {
|
|
|
if (status === 'complete') {
|
|
|
- getData(result.districtList[0])
|
|
|
+ getData(result.districtList[0])
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
selectP(val) {
|
|
|
if (this.status) {
|
|
|
+ this.$emit('provinceChange', val)
|
|
|
this.loadmap(val)
|
|
|
this.city = ''
|
|
|
this.district = ''
|
|
|
}
|
|
|
},
|
|
|
selectC(val) {
|
|
|
+ console.log(val)
|
|
|
if (this.status) {
|
|
|
this.loadmap(val)
|
|
|
this.district = ''
|