tomchentw / react-google-maps

React.js Google Maps integration component

Home Page:https://tomchentw.github.io/react-google-maps/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

f.setPosition is not a function

yusuffsaid opened this issue · comments

Issue: f.setPosition is not a function error when using @react-google-maps/api package

Description:
I encountered an issue while using the @react-google-maps/api package where I received a f.setPosition is not a function error. This error occurs when I call the setMarkerPosition function to set the position of the marker. Strangely, the error only appears in Sentry, and I couldn't reproduce it locally.

Steps to Reproduce:

Use the setMarkerPosition function to set the marker position:

const setMarkerPosition = (lat: any, lng: any) => {
    marker.setPosition({
        lat: lat,
        lng: lng,
    });
};

Call setMarkerPosition function using placeDetails from placesServices:

setMarkerPosition(
    placeDetails?.geometry?.location.lat(),
    placeDetails?.geometry?.location.lng()
);

Call setMarkerPosition function using the position from the current location button:

setMarkerPosition(position.coords.latitude, position.coords.longitude);

Expected Behavior:
The f.setPosition function should set the position of the marker correctly without any errors.

Actual Behavior:
The f.setPosition is not a function error is logged in Sentry when using the @react-google-maps/api package.

Environment:
Package version: "@react-google-maps/api": "^2.18.1",
Browser/Platform: Chrome Version:113.0.0

Screenshots/Error Logs:
Ekran Resmi 2023-06-16 17 33 43
Ekran Resmi 2023-06-16 17 33 30