Commit 6b4fb380 authored by Omar Luna Hernández's avatar Omar Luna Hernández
Browse files

Se guardan las coordenadas del marcador en el formulario

parent ef3a3a6a
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2,8 +2,14 @@ import { GoogleMap, Marker, useLoadScript } from "@react-google-maps/api";
import { useState, useMemo } from "react";
import { REACT_APP_GOOGLE_API_KEY } from "../../constants/api_keys";
import { LoadingScreen } from "../loading_screen/loading_screen";
import { UseFormSetValue } from "react-hook-form";
import { PlaceFormValues } from "../../infraestructure/entities/place";

export const MapComponent = () => {
interface props{
  setValue: UseFormSetValue<PlaceFormValues>;
}

export const MapComponent = ({setValue}: props) => {
  const {isLoaded} = useLoadScript({
    googleMapsApiKey: REACT_APP_GOOGLE_API_KEY
  });
@@ -15,6 +21,8 @@ export const MapComponent = () => {
      setMarker(true);
      setLatitude(event.latLng.lat());
      setLongitude(event.latLng.lng());
      setValue("latitude", event.latLng.lat(), {shouldValidate: true});
      setValue("longitude", event.latLng.lng(), {shouldValidate: true});
    }
  }