demarches-normaliennes/app/javascript/components/MapEditor/components/AddressInput.tsx
2022-02-09 10:29:00 +01:00

27 lines
682 B
TypeScript

import React from 'react';
import type { Point } from 'geojson';
import ComboAdresseSearch from '../../ComboAdresseSearch';
import { useFlyTo } from '../../shared/maplibre/hooks';
export function AddressInput() {
const flyTo = useFlyTo();
return (
<div
style={{
marginBottom: '10px'
}}
>
<ComboAdresseSearch
className="no-margin"
placeholder="Rechercher une adresse : saisissez au moins 2 caractères"
allowInputValues={false}
onChange={(_, result) => {
const geometry = result?.geometry as Point;
flyTo(17, geometry.coordinates as [number, number]);
}}
/>
</div>
);
}