|
|
|
@ -5,6 +5,8 @@ import { api } from "../api";
|
|
|
|
import { useEffect, useMemo, useState } from "react";
|
|
|
|
import { useEffect, useMemo, useState } from "react";
|
|
|
|
import { useMap } from "react-map-gl";
|
|
|
|
import { useMap } from "react-map-gl";
|
|
|
|
import parse from "wellknown";
|
|
|
|
import parse from "wellknown";
|
|
|
|
|
|
|
|
import { usePopup } from "../stores/usePopup.js";
|
|
|
|
|
|
|
|
import { useClickedPointConfig } from "../stores/useClickedPointConfig.js";
|
|
|
|
|
|
|
|
|
|
|
|
function useDebounce(value, delay) {
|
|
|
|
function useDebounce(value, delay) {
|
|
|
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
|
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
|
|
@ -22,6 +24,8 @@ export const AddressSearch = () => {
|
|
|
|
const { map } = useMap();
|
|
|
|
const { map } = useMap();
|
|
|
|
const [value, setValue] = useState("");
|
|
|
|
const [value, setValue] = useState("");
|
|
|
|
const debouncedValue = useDebounce(value);
|
|
|
|
const debouncedValue = useDebounce(value);
|
|
|
|
|
|
|
|
const { setPopup } = usePopup();
|
|
|
|
|
|
|
|
const { setClickedPointConfig } = useClickedPointConfig();
|
|
|
|
|
|
|
|
|
|
|
|
const { data } = useQuery(["address", debouncedValue], async () => {
|
|
|
|
const { data } = useQuery(["address", debouncedValue], async () => {
|
|
|
|
const result = await api.get(
|
|
|
|
const result = await api.get(
|
|
|
|
@ -56,6 +60,13 @@ export const AddressSearch = () => {
|
|
|
|
zoom: 13,
|
|
|
|
zoom: 13,
|
|
|
|
essential: true,
|
|
|
|
essential: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const feature = {
|
|
|
|
|
|
|
|
properties: option.item,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setPopup({ features: [feature], coordinates: geometry.coordinates });
|
|
|
|
|
|
|
|
setClickedPointConfig(feature.properties.id, false);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|