Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker not showing, using React 18 #1226

Open
sarahishamsaied opened this issue May 17, 2024 · 1 comment
Open

Marker not showing, using React 18 #1226

sarahishamsaied opened this issue May 17, 2024 · 1 comment

Comments

@sarahishamsaied
Copy link

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 (
<div style={{ height: "60vh", width: "100%" }}>
<GoogleMapReact
bootstrapURLKeys={{ key: "API_KEY" }}
center={center}
defaultZoom={11}
onClick={handleMapClick}
options={{
disableDefaultUI: true,
zoomControl: true,
draggableCursor: "pointer",
}}
>
{marker.lat && marker.lng && (

)}


{marker.lat} {marker.lng}



);
};

export default Map;

@oelbaga
Copy link

oelbaga commented May 30, 2024

We're getting the same. The console shows deprecations since February. Did this package not get updated yet?

Screenshot 2024-05-30 at 11 05 49 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants