fix: 地图标记点实现方式更改
This commit is contained in:
parent
37689880f1
commit
0323594841
|
@ -23,6 +23,7 @@
|
||||||
@click="clickMap"
|
@click="clickMap"
|
||||||
>
|
>
|
||||||
<el-amap-search-box visible @select="selectPoi" />
|
<el-amap-search-box visible @select="selectPoi" />
|
||||||
|
<el-amap-marker :position="position" />
|
||||||
</el-amap>
|
</el-amap>
|
||||||
{{ mapPoint }}
|
{{ mapPoint }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,7 +50,7 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
const emit = defineEmits<EmitProps>();
|
const emit = defineEmits<EmitProps>();
|
||||||
|
|
||||||
// 手动输入的坐标点
|
// 手动输入的坐标点(经纬度字符串)
|
||||||
const inputPoint = computed({
|
const inputPoint = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return props.point;
|
return props.point;
|
||||||
|
@ -67,7 +68,7 @@ const handleModalSubmit = () => {
|
||||||
modalVis.value = false;
|
modalVis.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 地图拾取的坐标点
|
// 地图拾取的坐标点(经纬度字符串)
|
||||||
const mapPoint = ref('');
|
const mapPoint = ref('');
|
||||||
|
|
||||||
const zoom = ref(12);
|
const zoom = ref(12);
|
||||||
|
@ -75,6 +76,9 @@ const center = ref([106.55, 29.56]);
|
||||||
let map: any = null;
|
let map: any = null;
|
||||||
let marker: any = null;
|
let marker: any = null;
|
||||||
|
|
||||||
|
// 地图经纬度
|
||||||
|
const position = ref<number[] | string[]>([]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地图初始化
|
* 地图初始化
|
||||||
* @param e
|
* @param e
|
||||||
|
@ -83,11 +87,7 @@ const initMap = (e: any) => {
|
||||||
map = e;
|
map = e;
|
||||||
|
|
||||||
const pointStr = mapPoint.value as string;
|
const pointStr = mapPoint.value as string;
|
||||||
if (marker) map.remove(marker);
|
position.value = pointStr ? pointStr.split(',') : center.value;
|
||||||
marker = new AMap.Marker({
|
|
||||||
position: pointStr ? pointStr.split(',') : center.value,
|
|
||||||
});
|
|
||||||
map.add(marker);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,13 +96,7 @@ const initMap = (e: any) => {
|
||||||
*/
|
*/
|
||||||
const clickMap = (e: any) => {
|
const clickMap = (e: any) => {
|
||||||
mapPoint.value = `${e.lnglat.lng},${e.lnglat.lat}`;
|
mapPoint.value = `${e.lnglat.lng},${e.lnglat.lat}`;
|
||||||
|
position.value = [e.lnglat.lng, e.lnglat.lat];
|
||||||
if (marker) map.remove(marker);
|
|
||||||
|
|
||||||
marker = new AMap.Marker({
|
|
||||||
position: [e.lnglat.lng, e.lnglat.lat],
|
|
||||||
});
|
|
||||||
map.add(marker);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -107,7 +107,7 @@ const props = defineProps({
|
||||||
// 组件类型
|
// 组件类型
|
||||||
itemType: {
|
itemType: {
|
||||||
type: String,
|
type: String,
|
||||||
default: () => 'object',
|
default: () => 'geoPoint',
|
||||||
},
|
},
|
||||||
// 下拉选择框下拉数据
|
// 下拉选择框下拉数据
|
||||||
options: {
|
options: {
|
||||||
|
|
Loading…
Reference in New Issue