react-leaflet-google-layer
react-leaflet-google-layer copied to clipboard
Cannot specify map type or any other GoogleMutant property
When I'm trying to specify the map type I get this error: 'Property 'type' does not exist on type 'IntrinsicAttributes & LayerProps & IProps & RefAttributes<GridLayer>'.'
In fact, I cannot seem to set any of the GoogleMutant properties
My code:
<ReactLeafletGoogleLayer apiKey={config.googleMapsApiKey} type="satellite" />
I am using react leaflet v3 and using v2.0.4 of this library
@Matthias-Claes Hi,
Can you please add a codesandbox to show the issue?
I'm also seeing this issue in VS Code, but it's not reproducible in CodeSandbox. I think it's something around the fact that the type L.gridLayer.GoogleMutantOptions seems to exist as a side-effect of import 'leaflet.gridlayer.googlemutant';. For some reason, VS Code seems to import L.gridLayer.GoogleMutantOptions as an any type. Here's a screenshot of the issue:

I've been trying to narrow down the issue and it seems that if I remove "react-leaflet": "^3.2.2", as a dependency, the error goes away. When I add it back, the error returns. However, I have a minimal test project going that also includes react-leaflet and it doesn't seem to have the same problem, so I'm continuing to dig into it.
OK -- so the problem can be fixed by upgrading yarn. I was using version 3.0.2, and upgrading to version 3.2.0-rc.3 fixes the problem. Examining https://github.com/yarnpkg/berry/blob/master/CHANGELOG.md for v3.1.0, it looks like perhaps the relevant line is maybe:
Direct portal dependencies for node_modules installs will now be given priority during hoisting, preventing cases when indirect regular dependencies would block the way for direct portal dependencies.
However, I don't understand what most of those words mean so it could have been something else they changed. Anyway, I think the solution to this one might be just to upgrade yarn.
I have the same now (after three years) in react-leaflet version 4.2.1
@dennisat Hi, can you please add a codesandbox with the issue?