Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
ZvonimirSun committed Mar 16, 2024
1 parent 66459fa commit d30ce32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/utils/leaflet.ChineseLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ ChineseLayer.include({
},
})

export const csysConvert = ChineseLayer.prototype.csysConvert

function transform(lng, lat) {
let dLat = transformLat(lng - 105.0, lat - 35.0)
let dLng = transformLng(lng - 105.0, lat - 35.0)
Expand Down
6 changes: 3 additions & 3 deletions src/utils/mapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'leaflet/dist/leaflet.css'
import type { Control, ControlPosition, Map, MapOptions, TileLayer } from 'leaflet'
import { Icon, LatLng, control, layerGroup, map } from 'leaflet'
import config from '@/config'
import { ChineseLayer, chineseLayer } from '@/utils/leaflet.ChineseLayer.js'
import { chineseLayer, csysConvert } from '@/utils/leaflet.ChineseLayer.js'
import $axios from '@/plugins/Axios'

Icon.Default.prototype.options.iconUrl = `https://jsdelivr.${config.cdnHost}/gh/zvonimirsun/leaflet-color-markers@master/img/marker-icon-blue.png`
Expand Down Expand Up @@ -277,7 +277,7 @@ async function getLocation(address: string): Promise<{
})
if (res.data.status === '1' && Number(res.data.count) > 0) {
const info = res.data.geocodes[0]
const latLng = ChineseLayer.prototype.csysConvert.gcj02_To_gps84(Number.parseFloat(info.location.split(',')[0]), Number.parseFloat(info.location.split(',')[1]))
const latLng = csysConvert.gcj02_To_gps84(Number.parseFloat(info.location.split(',')[0]), Number.parseFloat(info.location.split(',')[1]))
return {
latLng: new LatLng(latLng.lat, latLng.lng),
address: info.formatted_address,
Expand All @@ -289,7 +289,7 @@ async function getLocation(address: string): Promise<{
}

async function getAddress(location: LatLng): Promise<string> {
const gaodeLatLng = ChineseLayer.prototype.csysConvert.gps84_To_gcj02(location.lng, location.lat)
const gaodeLatLng = csysConvert.gps84_To_gcj02(location.lng, location.lat)
const res = await $axios.get('https://amap.api.iszy.xyz/v3/geocode/regeo', {
params: {
location: `${gaodeLatLng.lng},${gaodeLatLng.lat}`,
Expand Down

0 comments on commit d30ce32

Please sign in to comment.