add form create inquiryPrivacyFencing

This commit is contained in:
Amirhossein Mahmoodi
2024-07-13 11:10:53 +03:30
parent 56fbe67483
commit 4efc228d31
5 changed files with 539 additions and 388 deletions

View File

@@ -1,6 +1,5 @@
import { useFormikContext } from "formik";
import { useRef } from "react";
import { Marker, useMapEvents } from "react-leaflet"
import { Marker, useMapEvents } from "react-leaflet";
const prefix = process.env.NODE_ENV === "production" ? "/v3" : "";
@@ -10,21 +9,20 @@ const locationMarker = L.icon({
iconAnchor: [25, 50],
});
const MarkerLocation = () => {
const { setFieldValue } = useFormikContext()
const MarkerLocation = ({ setValue }) => {
const location = useRef();
const map = useMapEvents({
move: (e) => {
const latlon = e.target.getCenter()
location.current?.setLatLng(latlon);
setFieldValue('lat', latlon.lat)
setFieldValue('lon', latlon.lng)
setValue('lat', latlon.lat)
setValue('lon', latlon.lng)
},
zoom: (e) => {
const latlon = e.target.getCenter()
location.current?.setLatLng(latlon);
setFieldValue('lat', latlon.lat)
setFieldValue('lon', latlon.lng)
setValue('lat', latlon.lat)
setValue('lon', latlon.lng)
},
});
return (