Skip to content

Commit

Permalink
fix(latLng): 修复点击拾取功能
Browse files Browse the repository at this point in the history
  • Loading branch information
ZvonimirSun committed Mar 7, 2025
1 parent 5472301 commit 359c551
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
"onElementRemoval": true,
"usePreferredReducedTransparency": true,
"useSSRWidth": true,
"useCountdown": true
"useCountdown": true,
"createRef": true
}
}
7 changes: 4 additions & 3 deletions src/tools/latLng.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ onMounted(() => {
window.requestAnimationFrame(() => {
const center = map.getCenter()
centerMarker.setLatLng(center)
updatePopupContent(center.wrap(), centerMarker.getPopup())
updatePopupContent(center, centerMarker.getPopup())
})
})
map.on('click', ({ latlng }: { latlng: LatLng }) => {
latlng = latlng.wrap()
keyword.value = `${latlng.lng},${latlng.lat}`
const wrapLatLng = latlng.wrap()
keyword.value = `${wrapLatLng.lng},${wrapLatLng.lat}`
locateLocation(latlng)
})
if ('geolocation' in navigator) {
Expand Down Expand Up @@ -88,6 +88,7 @@ function updatePopupContent(location: LatLng, popup?: Popup, address?: string):
closeOnClick: false,
})
}
location = location.wrap()
const lat = location.lat
const lng = location.lng
let content = ''
Expand Down
2 changes: 2 additions & 0 deletions src/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare global {
const createInjectionState: typeof import('@vueuse/core')['createInjectionState']
const createPinia: typeof import('pinia')['createPinia']
const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn']
const createRef: typeof import('@vueuse/core')['createRef']
const createReusableTemplate: typeof import('@vueuse/core')['createReusableTemplate']
const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable']
const createTemplatePromise: typeof import('@vueuse/core')['createTemplatePromise']
Expand Down Expand Up @@ -351,6 +352,7 @@ declare module 'vue' {
readonly createInjectionState: UnwrapRef<typeof import('@vueuse/core')['createInjectionState']>
readonly createPinia: UnwrapRef<typeof import('pinia')['createPinia']>
readonly createReactiveFn: UnwrapRef<typeof import('@vueuse/core')['createReactiveFn']>
readonly createRef: UnwrapRef<typeof import('@vueuse/core')['createRef']>
readonly createReusableTemplate: UnwrapRef<typeof import('@vueuse/core')['createReusableTemplate']>
readonly createSharedComposable: UnwrapRef<typeof import('@vueuse/core')['createSharedComposable']>
readonly createTemplatePromise: UnwrapRef<typeof import('@vueuse/core')['createTemplatePromise']>
Expand Down
1 change: 1 addition & 0 deletions src/utils/gisUtils/utils/addressUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function getLocation(address: string): Promise<{
}

export async function getAddress(location: LatLng): Promise<string> {
location = location.wrap()
const gaodeLatLng = csysConvert.gps84_To_gcj02(location.lng, location.lat)
const res = await $axios.get(`${config.apiOrigin}/amap/v3/geocode/regeo`, {
params: {
Expand Down

0 comments on commit 359c551

Please sign in to comment.