import React, { useState, useEffect } from "react"; import GoogleMapReact from "google-map-react"; import { IoIosPin } from "react-icons/io"; const Marker = ({ lat, lng }: { lat: number; lng: number }) => ( ); const Map = ({ onSubmitLocation, }: { onSubmitLocation?: (location: { lat: number; lng: number }) => void; }) => { const [center, setCenter] = useState({ lat: 0, lng: 0 }); const [marker, setMarker] = useState<{ lat: number | null; lng: number | null; }>({ lat: null, lng: null }); useEffect(() => { navigator.geolocation.getCurrentPosition( (position) => { setCenter({ lat: position.coords.latitude, lng: position.coords.longitude, }); }, (error) => { console.error("Error obtaining location", error); setCenter({ lat: 0, lng: 0 }); } ); }, []); const handleMapClick = ({ lat, lng, }: { lat: number | null; lng: number | null; }) => { setMarker({ lat, lng }); onSubmitLocation && lat && lng && onSubmitLocation({ lat, lng }); }; return ( {marker.lat && marker.lng && ( )} {marker.lat} {marker.lng} ); }; export default Map;
Activity
oelbaga commentedon May 30, 2024
We're getting the same. The console shows deprecations since February. Did this package not get updated yet?
ciruz commentedon Jul 10, 2024
There is a fix here: #1224