react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

Changing groundOverlay url does not rerender

Open randomdude583 opened this issue 2 years ago • 1 comments

I have a google map displayed in my react project, and I am able to display an image overlay. However, if I update the URL, I cannot get the map to update with the new image.

I have a sample drawn up in codesandbox here: https://codesandbox.io/s/upbeat-sea-yfvuio?file=/src/App.js

randomdude583 avatar Mar 28 '22 23:03 randomdude583

Looking into the code I found this note:

For GroundOverlay, url and bounds are passed in to constructor and are immutable after instantiated. This is the behavior of Google Maps JavaScript API v3 ( See https://developers.google.com/maps/documentation/javascript/reference#GroundOverlay) Hence, use the corresponding two props provided by \`react-google-maps-api\`, url and bounds. In some cases, you'll need the GroundOverlay component to reflect the changes of url and bounds. You can leverage the React's key property to remount the component. Typically, just \`key={url}\` would serve your need. See https://github.com/tomchentw/react-google-maps/issues/655

However, I also found that this limitation of the JavaScript API may not be the case anymore: https://stackoverflow.com/questions/6291730/is-it-possible-to-change-image-of-google-maps-groundoverlay-using-javascript#:~:text=This%20has%20changed%20from%202011.

Is there any chance of updating this library to leverage that new feature?

randomdude583 avatar Mar 28 '22 23:03 randomdude583