|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <el-form-item label="地区:">
|
|
|
+ <el-form-item label="经纬度:">
|
|
|
<el-cascader
|
|
|
v-model="selectedOptions"
|
|
|
placeholder="请选择地区"
|
|
|
@@ -23,14 +23,13 @@
|
|
|
ref="markerRef"
|
|
|
:geometries="geometries"
|
|
|
:styles="styles"
|
|
|
- :options="options"
|
|
|
@click="openInfo"
|
|
|
/>
|
|
|
</tlbs-map>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref } from 'vue'
|
|
|
+import { ref, watch } from 'vue'
|
|
|
// 地区选择
|
|
|
import { regionData, codeToText } from 'element-china-area-data'
|
|
|
import { jsonp } from 'vue-jsonp'
|
|
|
@@ -41,7 +40,6 @@ const handleChange = async(value) => {
|
|
|
const city = codeToText[value[1]] // 市-->
|
|
|
const district = codeToText[value[2]] // 区-->
|
|
|
const fullAddress = `${province}${city}${district}`
|
|
|
- console.log(fullAddress)
|
|
|
if (value.length < 3) {
|
|
|
console.log('请选择完整的省市区')
|
|
|
return
|
|
|
@@ -50,13 +48,15 @@ const handleChange = async(value) => {
|
|
|
jsonp('https://apis.map.qq.com/ws/geocoder/v1/?address=', {
|
|
|
output: 'jsonp',
|
|
|
address: fullAddress,
|
|
|
- key: 'GDFBZ-AXD6B-2TPUJ-JBLEX-STUGE-DGBZH'
|
|
|
+ key: '3SVBZ-6MYYZ-Q75X5-7YN43-BMIBZ-YABND'
|
|
|
}).then(res => {
|
|
|
- console.log('返回经纬度', res.result.location)
|
|
|
+ center.value = res.result.location
|
|
|
}).catch(err => {
|
|
|
console.log('地图错误:', err)
|
|
|
})
|
|
|
}
|
|
|
+const openInfo = (val) => {
|
|
|
+}
|
|
|
const selectedOptions = ref('')
|
|
|
const control = {
|
|
|
scale: {},
|
|
|
@@ -81,19 +81,10 @@ const zoom = ref(10)
|
|
|
const mapOption = ref({
|
|
|
mapStyleId: 'style1'
|
|
|
})
|
|
|
-const geometries = ref([{ styleId: 'marker', position: { lat: 39.91799, lng: 116.397027 }}])
|
|
|
+const geometries = ref([{ styleId: 'marker', position: useCoordinate.place }])
|
|
|
const onClick = (e) => {
|
|
|
- console.log(e.latLng)
|
|
|
- // geometries.value = [
|
|
|
- // {
|
|
|
- // styleId: 'marker',
|
|
|
- // position: { lat: 28.7052848, lng: 113.5759597 },
|
|
|
- // },
|
|
|
- // {
|
|
|
- // styleId: 'marker',
|
|
|
- // position: { lat: e.latLng.lat, lng: e.latLng.lng },
|
|
|
- // },
|
|
|
- // ]
|
|
|
+ geometries.value = [{ styleId: 'marker', position: { lat: e.latLng.lat, lng: e.latLng.lng }}]
|
|
|
+ useCoordinate.changeModifyPlace({ lat: e.latLng.lat, lng: e.latLng.lng })
|
|
|
}
|
|
|
|
|
|
const onMapInited = () => {
|
|
|
@@ -102,5 +93,10 @@ const onMapInited = () => {
|
|
|
// console.log(markerRef.value.marker)
|
|
|
}
|
|
|
|
|
|
+watch(() => useCoordinate.place, () => {
|
|
|
+ center.value = useCoordinate.place
|
|
|
+ geometries.value = [{ styleId: 'marker', position: useCoordinate.place }]
|
|
|
+})
|
|
|
+
|
|
|
</script>
|
|
|
|