|
@@ -3,7 +3,8 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
- import { computed,getCurrentInstance,nextTick, ref } from "vue";
|
|
|
|
|
|
+ import { computed,getCurrentInstance,nextTick, ref,onMounted } from "vue";
|
|
|
|
+ import $bus from '@/benyun/utils/bus.js'
|
|
const { proxy } = getCurrentInstance();
|
|
const { proxy } = getCurrentInstance();
|
|
const value = ref('')
|
|
const value = ref('')
|
|
const config = ref({})
|
|
const config = ref({})
|
|
@@ -13,6 +14,7 @@
|
|
const zoom = ref(12) //地图层级
|
|
const zoom = ref(12) //地图层级
|
|
const emit = defineEmits();
|
|
const emit = defineEmits();
|
|
const _id = ref('')
|
|
const _id = ref('')
|
|
|
|
+ const geocoder = ref('');
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
propConfig:{},
|
|
propConfig:{},
|
|
propValue:{},
|
|
propValue:{},
|
|
@@ -64,7 +66,14 @@
|
|
const initMap = callback => {
|
|
const initMap = callback => {
|
|
if(map.value) return
|
|
if(map.value) return
|
|
map.value = new T.Map(_id.value);
|
|
map.value = new T.Map(_id.value);
|
|
- map.value.centerAndZoom(new T.LngLat(109.411030,24.328160), zoom.value);
|
|
|
|
|
|
+ //创建对象
|
|
|
|
+ geocoder.value = new T.Geocoder();
|
|
|
|
+ if(lng.value && lat.value){
|
|
|
|
+ map.value.centerAndZoom(new T.LngLat(lng.value,lat.value), zoom.value);
|
|
|
|
+ }else{
|
|
|
|
+ map.value.centerAndZoom(new T.LngLat(109.411030,24.328160), zoom.value);
|
|
|
|
+ }
|
|
|
|
+
|
|
const cp = new T.CoordinatePickup(map.value, {callback: getLngLat})
|
|
const cp = new T.CoordinatePickup(map.value, {callback: getLngLat})
|
|
cp.addEvent();
|
|
cp.addEvent();
|
|
if(callback) {
|
|
if(callback) {
|
|
@@ -96,12 +105,23 @@
|
|
getLngLat({lng:lng.value,lat:lat.value})
|
|
getLngLat({lng:lng.value,lat:lat.value})
|
|
})
|
|
})
|
|
}else{
|
|
}else{
|
|
|
|
+ map.value.centerAndZoom(new T.LngLat(lng.value,lat.value), zoom.value);
|
|
getLngLat({lng:lng.value,lat:lat.value})
|
|
getLngLat({lng:lng.value,lat:lat.value})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ const searchResult = result => {
|
|
|
|
+ if(result.getStatus() == 0){
|
|
|
|
+ map.value.panTo(result.getLocationPoint(), zoom.value);
|
|
|
|
+ // map.value.clearOverLays();
|
|
|
|
+ // //创建标注对象
|
|
|
|
+ // var marker = new T.Marker(result.getLocationPoint());
|
|
|
|
+ // //向地图上添加标注
|
|
|
|
+ // map.value.addOverLay(marker);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|
|
getValue,getConfig,setConfig,clearValue,setValue
|
|
getValue,getConfig,setConfig,clearValue,setValue
|
|
@@ -118,7 +138,18 @@
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
initMap()
|
|
initMap()
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+ // 接收数据
|
|
|
|
+onMounted(()=>{
|
|
|
|
+ $bus.on('areaEvent',(data)=>{
|
|
|
|
+ let area = data.area ? data.area : '';
|
|
|
|
+ if(area){
|
|
|
|
+ area = area.replaceAll('/','');
|
|
|
|
+ if(geocoder.value){
|
|
|
|
+ geocoder.value.getPoint(area, searchResult);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+})
|
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|