Skip to content

Don't crash map creation when Google Maps basemaps fail to load (#2701) - #2841

Open
HafizMHussain wants to merge 1 commit into
gee-community:masterfrom
HafizMHussain:fix-google-maps-basemap-crash
Open

Don't crash map creation when Google Maps basemaps fail to load (#2701)#2841
HafizMHussain wants to merge 1 commit into
gee-community:masterfrom
HafizMHussain:fix-google-maps-basemap-crash

Conversation

@HafizMHussain

Copy link
Copy Markdown

Fixes #2701.

When GOOGLE_MAPS_API_KEY is set, geemap eagerly builds Google Maps tile
providers, which POST to the Maps Tiles createSession endpoint. For
accounts/regions without Tiles API access this returns 403 and raises a
RuntimeError, which propagated out of _get_available_basemaps() and
crashed 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/except that logs a warning and
continues with the standard basemaps, in both geemap.core.Map and
geemap.maplibregl.Map.

Testing

  • Added a regression test (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.
  • Ran locally: tests/test_core.py20 passed. black --check passes.

This implements the "display a warning when GOOGLE_MAPS_API_KEY is set but
authentication fails" option from the issue, without changing the public API.

…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.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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

Successfully merging this pull request may close these issues.

Geemap should be able to disregard GOOGLE_MAPS_API_KEY in environment

1 participant