Don't crash map creation when Google Maps basemaps fail to load (#2701) - #2841
Open
HafizMHussain wants to merge 1 commit into
Open
Don't crash map creation when Google Maps basemaps fail to load (#2701)#2841HafizMHussain wants to merge 1 commit into
HafizMHussain wants to merge 1 commit into
Conversation
…community#2701) When GOOGLE_MAPS_API_KEY is set, geemap eagerly creates Google Maps tile providers, which POST to the Maps Tiles createSession endpoint. For accounts/regions without Tiles API access this returns 403 and raises, which propagated out of _get_available_basemaps() and crashed Map() creation even when the user never requested Google tiles. Wrap the Google basemap loading in a try/except that logs a warning and continues with the standard basemaps, in both geemap.core.Map and geemap.maplibregl.Map. Adds a regression test that simulates the failure and asserts the map is still created with basemaps available and a warning emitted.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2701.
When
GOOGLE_MAPS_API_KEYis set, geemap eagerly builds Google Maps tileproviders, which POST to the Maps Tiles
createSessionendpoint. Foraccounts/regions without Tiles API access this returns 403 and raises a
RuntimeError, which propagated out of_get_available_basemaps()andcrashed
Map()creation — even when the user never requested Google tiles(the reporter hit this as an EU user).
Fix
Wrap the Google-basemap loading in a
try/exceptthat logs a warning andcontinues with the standard basemaps, in both
geemap.core.Mapandgeemap.maplibregl.Map.Testing
test_available_basemaps_survive_google_maps_error)that simulates the failure and asserts the map is still created with basemaps
available and a warning emitted.
tests/test_core.py→ 20 passed.black --checkpasses.This implements the "display a warning when
GOOGLE_MAPS_API_KEYis set butauthentication fails" option from the issue, without changing the public API.