Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch between OSM and GMap at runtime #31

Closed
Aky97567 opened this issue Mar 28, 2022 · 1 comment
Closed

Switch between OSM and GMap at runtime #31

Aky97567 opened this issue Mar 28, 2022 · 1 comment

Comments

@Aky97567
Copy link

Aky97567 commented Mar 28, 2022

I would like to switch between OSM and GMap tiles based on a boolean:

const GMapsEnabled = false;
...
<MapContainer>
  {GMapsEnabled ? (<ReactLeafletGoogleLayer apiKey={apiKey} type="satellite" />) :
    (<TileLayer
      attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
      url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
      maxZoom={maxZoom}
      maxNativeZoom={maxNativeZoom}
    />
  )}
</MapContainer>

However, the tiles from OSM have stopped loading. My guess is that the tile urls for GMaps are different. It would be helpful if there is a way to have this configurability.

@Aky97567
Copy link
Author

I am unable to reproduce this with codesandbox. I think I am doing something wrong. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant