visgl / react-google-maps

React components and hooks for the Google Maps JavaScript API
https://visgl.github.io/react-google-maps/
MIT License
1.17k stars 90 forks source link

[Bug] `renderingType` is incompatible with `reuseMaps` #471

Closed anliting closed 1 week ago

anliting commented 1 month ago

Description

I get an error like this:

Uncaught Error: Setting map 'renderingType' after instantiation is not supported.

It does not throw if only one of renderingType and reuseMaps is supplied.

Steps to Reproduce

  1. Create a Map like this:

    <Map
    renderingType={google.maps.RenderingType.VECTOR}
    reuseMaps
    />
  2. Mount it.

  3. Unmount it.

  4. Mount it.

Environment

Logs

main.js:6937 Uncaught Error: Setting map 'renderingType' after instantiation is not supported.
    at lca.renderingType_changed (main.js:367:1635)
    at Xk (main.js:140:251)
    at Xk (main.js:140:311)
    at _.Vk.set (main.js:260:719)
    at jo.setRenderingType (main.js:148:354)
    at _.Vk.setValues (main.js:261:242)
    at main.js:23769:12
    at commitHookEffectListMount (main.js:6949:114)
    at commitPassiveMountOnFiber (main.js:7162:1577)
    at commitPassiveMountEffects_complete (main.js:7162:872)
usefulthink commented 1 month ago

I wasn't aware that the renderingType can't be changed after the map is created, we'll have to adjust our implementation so renderingType is treated like the mapId, creating a new map instance when changed this should then also make it work with reuseMaps.