Skip to content

Commit

Permalink
Improve google_maps_api_key function
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Apr 29, 2024
1 parent 27ed73f commit afa285d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions geemap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16325,12 +16325,12 @@ def google_map_tiles(
return gmap_providers.get(map_type)


def google_maps_api_key(token_name="MAPS_API_KEY"):
def google_maps_api_key(lookup_key: str = "MAPS_API_KEY") -> Optional[str]:
"""
Retrieves the Google Maps API key from the environment or Colab user data.

Args:
token_name (str, optional): The name of the environment variable or
lookup_key (str, optional): The name of the environment variable or
Colab user data key where the API key is stored.
Defaults to 'MAPS_API_KEY'.

Expand All @@ -16340,8 +16340,8 @@ def google_maps_api_key(token_name="MAPS_API_KEY"):
if in_colab_shell():
from google.colab import userdata

MAPS_API_KEY = userdata.get(token_name)
env_value = userdata.get(lookup_key)
else:
MAPS_API_KEY = os.environ.get(token_name, None)
env_value = os.environ.get(lookup_key, None)

return MAPS_API_KEY
return env_value

0 comments on commit afa285d

Please sign in to comment.