Added osmAddress api route

Related to #19
This commit is contained in:
2023-07-15 11:08:15 +03:00
parent 2ce0e5b65d
commit cb848739e5
5 changed files with 65 additions and 37 deletions

View File

@ -0,0 +1,12 @@
import { LatLng } from 'leaflet'
import { OsmAddressResponse } from './types'
const initialOsmAddress = ''
const composeOsmAddressURL = (addressPosition: LatLng) =>
`${location.protocol}//nominatim.openstreetmap.org/reverse?format=json&accept-language=ru&lat=${addressPosition.lat}&lon=${addressPosition.lng}`
const processOsmAddress = (data: OsmAddressResponse): string =>
data.display_name
export { initialOsmAddress, composeOsmAddressURL, processOsmAddress }

View File

@ -0,0 +1,17 @@
import { isObject } from '../../utils/types'
type OsmAddressResponse = {
display_name: string
}
const isOsmAddressResponse = (obj: unknown): obj is OsmAddressResponse => isObject(obj, {
'display_name': 'string',
})
export type {
OsmAddressResponse,
}
export {
isOsmAddressResponse,
}