GithubHelp home page GithubHelp logo

Comments (18)

shellbryson avatar shellbryson commented on June 2, 2024 6

Update: I notice further back in the issues someone posted a link to their fork. It has almost identical functionality, but doesn't appear to suffer the issue described above:

https://github.com/giorgiabosello/google-maps-react-markers

from google-map-react.

apurvjha123 avatar apurvjha123 commented on June 2, 2024 4

@shellbryson @tao-qian @jarlnartey @Fullbusters @thinhnuine I have face the same issue and debugged literally 8+ hrs , And finally I found out just remove restrictmode from index.js in react

From :-

  <React.StrictMode>
    <App />
  </React.StrictMode>
);```

To:-

```root.render(

    <App />

);```

Happy Hacking !

from google-map-react.

shellbryson avatar shellbryson commented on June 2, 2024 2

A word of caution: Strict mode is there for a reason and disabling it not a risk worth taking in a production app, in my opinion.

from google-map-react.

tao-qian avatar tao-qian commented on June 2, 2024 1

Thanks! Switched to https://github.com/giorgiabosello/google-maps-react-markers and it worked well for me so far!

from google-map-react.

shellbryson avatar shellbryson commented on June 2, 2024

I'm having the same issue: Spent hours trying to figure out why this doesn't work. Any markers place on the map do drag when the map is moved or zoomed, but soon as the action stops, the marker components reposition themselves at their initial position (that is, relative to viewport, rather than relative to the map).

const styleMap={
  display: "block",
  position: "relative",
  marginTop: "2rem",
  width: "100%",
  height: "90vh",
  overflow: "hidden",
}

const pinStyle = {

}

const LocationPin = ({ text }) => (
  <div style={ pinStyle }>
    <PushPinOutlinedIcon />
    <p className="">{text}</p>
  </div>
)

export default function MapView() {

  const [locations, setLocations] = useState([]);
  const [isLoaded, setIsLoaded] = useState(false);

  const q = query(collection(db, "locations"));

  const getLocations = async () => {
    const querySnapshot = await getDocs(q);
    const l = [];
    querySnapshot.forEach((doc) => {
      l.push({
        ...doc.data(),
        id: doc.id
      });
    });
    console.log("ESFF: loaded locations", l);
    setLocations(l);
    setIsLoaded(true)
  }

  useEffect(() => {
    getLocations();
  }, [])

  const defaultLocation = {
    center: {
      lat: 55.9579741,
      lng: -3.1966372,
    },
    zoom: 13
  }

  return (
    <>
      { isLoaded &&
        <Box style={styleMap}>
          <GoogleMapReact
            bootstrapURLKeys={{ key: import.meta.env.VITE_GOOGLEMAPS_API_KEY }}
            yesIWantToUseGoogleMapApiInternals
            defaultCenter={defaultLocation.center}
            defaultZoom={defaultLocation.zoom}>

            {locations.map((place) => (
              <LocationPin
                key={place.id}
                text={place.title}
                lat={parseFloat(place.lat)}
                lng={parseFloat(place.lng)}
              />
            ))}

          </GoogleMapReact>
        </Box>
      }
    </>
  )

from google-map-react.

Fullbusters avatar Fullbusters commented on June 2, 2024

Any updates/fixes?

from google-map-react.

GowriSh1393 avatar GowriSh1393 commented on June 2, 2024

any fixes?

from google-map-react.

thinhnuine avatar thinhnuine commented on June 2, 2024

Same issue

from google-map-react.

MahourPriyanka avatar MahourPriyanka commented on June 2, 2024

Facing same issue

from google-map-react.

jarlnartey avatar jarlnartey commented on June 2, 2024

Same issue. Follwing...

from google-map-react.

shellbryson avatar shellbryson commented on June 2, 2024

Use the forked project mentioned above. That works.

from google-map-react.

juancarloselorriaga avatar juancarloselorriaga commented on June 2, 2024

Any update? Following...

from google-map-react.

apurvjha123 avatar apurvjha123 commented on June 2, 2024

A word of caution: Strict mode is there for a reason and disabling it not a risk worth taking in a production app, in my opinion.

True , This is a major issue , But this repo is not active now.

from google-map-react.

vx17rt avatar vx17rt commented on June 2, 2024

The best solution here is to switch to the best map library - Mapbox. However, if you're forced to use google maps like me - the only option is to use their official react-wrapper library and forget about declarative React API

from google-map-react.

anayagaray98 avatar anayagaray98 commented on June 2, 2024

This was my solution: https://github.com/giorgiabosello/google-maps-react-markers

from google-map-react.

mxmzb avatar mxmzb commented on June 2, 2024

I have this with Next.js in dev mode. When I build the app and run the production build, it works fine. Maybe it has to do with some reload mechanism that is employed only in dev mode.

from google-map-react.

stephen-simone avatar stephen-simone commented on June 2, 2024

I have this with Next.js in dev mode. When I build the app and run the production build, it works fine. Maybe it has to do with some reload mechanism that is employed only in dev mode.

This seems to have solved my issue. It appears to be related to hot reloading in NextJs.

from google-map-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.