mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
nominatim search (without working dialog)
This commit is contained in:
parent
c3e136cebb
commit
b20a3445d1
27 changed files with 450 additions and 61 deletions
|
@ -11,6 +11,7 @@ import {
|
|||
configWithToken,
|
||||
} from './middleware';
|
||||
import { IRoute } from '~/redux/map/types';
|
||||
import { INominatimResult } from '~/redux/types';
|
||||
|
||||
const arrayToObject = (array: any[], key: string): {} =>
|
||||
array.reduce((obj, el) => ({ ...obj, [el[key]]: el }), {});
|
||||
|
@ -180,6 +181,36 @@ export const checkOSRMService = (bounds: LatLngLiteral[]): Promise<boolean> =>
|
|||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
export const checkNominatimService = (): Promise<boolean> =>
|
||||
CLIENT &&
|
||||
CLIENT.NOMINATIM_TEST_URL &&
|
||||
axios
|
||||
.get(CLIENT.NOMINATIM_TEST_URL)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
export const searchNominatim = (query: string) =>
|
||||
CLIENT &&
|
||||
CLIENT.NOMINATIM_URL &&
|
||||
axios
|
||||
.get(`${CLIENT.NOMINATIM_URL}${query}`, { params: { format: 'json', country_code: 'ru', 'accept-language': 'ru_RU' } })
|
||||
.then(
|
||||
data =>
|
||||
data &&
|
||||
data.data &&
|
||||
data.data.map(
|
||||
(item): INominatimResult => ({
|
||||
id: item.place_id,
|
||||
latlng: {
|
||||
lat: item.lat,
|
||||
lng: item.lon,
|
||||
},
|
||||
title: item.display_name,
|
||||
})
|
||||
)
|
||||
)
|
||||
.catch(() => []);
|
||||
|
||||
export const dropRoute = ({ address, token }: { address: string; token: string }): Promise<any> =>
|
||||
axios
|
||||
.delete(API.DROP_ROUTE, configWithToken(token, { data: { address } }))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue