diff --git a/leafmap/common.py b/leafmap/common.py index 584667e86b..a853bb6962 100644 --- a/leafmap/common.py +++ b/leafmap/common.py @@ -14853,3 +14853,18 @@ def find_max_value_coords( x, y = transformer.transform(x, y) return x, y, max_value + + +def read_geojson(data: str, **kwargs: Any) -> Dict[str, Any]: + """ + Fetches and parses a GeoJSON file from a given URL. + + Args: + data (str): The URL of the GeoJSON file. + **kwargs (Any): Additional keyword arguments to pass to the requests.get() method. + + Returns: + Dict[str, Any]: The parsed GeoJSON data. + """ + + return requests.get(data, **kwargs).json() diff --git a/leafmap/maplibregl.py b/leafmap/maplibregl.py index d8a44eb68e..90391c5137 100644 --- a/leafmap/maplibregl.py +++ b/leafmap/maplibregl.py @@ -3316,7 +3316,7 @@ def construct_maptiler_style(style: str, api_key: Optional[str] = None) -> str: This function generates a URL for accessing a specific MapTiler map style. If an API key is not provided, it attempts to retrieve one using a predefined method. If the request to MapTiler fails, it defaults to - a "dark-matter" style. + a "liberty" style. Args: style (str): The name of the MapTiler style to be accessed. It can be one of the following: @@ -3326,7 +3326,7 @@ def construct_maptiler_style(style: str, api_key: Optional[str] = None) -> str: attempts to retrieve the API key using a predefined method. Defaults to None. Returns: - str: The URL for the requested MapTiler style. If the request fails, returns a URL for the "dark-matter" style. + str: The URL for the requested MapTiler style. If the request fails, returns a URL for the "liberty" style. Raises: requests.exceptions.RequestException: If the request to the MapTiler API fails. @@ -3340,9 +3340,9 @@ def construct_maptiler_style(style: str, api_key: Optional[str] = None) -> str: response = requests.get(url) if response.status_code != 200: print( - "Failed to retrieve the MapTiler style. Defaulting to 'dark-matter' style." + "Failed to retrieve the MapTiler style. Defaulting to OpenFreeMap 'liberty' style." ) - url = "dark-matter" + url = "https://tiles.openfreemap.org/styles/liberty" return url