diff --git a/geemap/basemaps.py b/geemap/basemaps.py index b814a3ded0..0662dd0d22 100644 --- a/geemap/basemaps.py +++ b/geemap/basemaps.py @@ -60,7 +60,7 @@ # Custom WMS tile services. WMS_TILES = { "FWS NWI Wetlands": { - "url": "https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?", + "url": "https://fwspublicservices.wim.usgs.gov/wetlandsmapservice/services/Wetlands/MapServer/WMSServer?", "layers": "1", "name": "FWS NWI Wetlands", "attribution": "FWS", diff --git a/geemap/foliumap.py b/geemap/foliumap.py index 3288f271c5..2e7ffc263b 100644 --- a/geemap/foliumap.py +++ b/geemap/foliumap.py @@ -1501,20 +1501,21 @@ def add_osm_from_bbox( def add_points_from_xy( self, - data, - x="longitude", - y="latitude", - popup=None, - min_width=100, - max_width=200, - layer_name="Marker Cluster", - color_column=None, - marker_colors=None, - icon_colors=["white"], - icon_names=["info"], - angle=0, - prefix="fa", - add_legend=True, + data: Union[str, pd.DataFrame], + x: Optional[str] = "longitude", + y: Optional[str] = "latitude", + popup: Optional[List] = None, + min_width: Optional[int] = 100, + max_width: Optional[int] = 200, + layer_name: Optional[str] = "Marker Cluster", + color_column: Optional[str] = None, + marker_colors: Optional[List] = None, + icon_colors: Optional[List] = ["white"], + icon_names: Optional[List] = ["info"], + angle: Optional[int] = 0, + prefix: Optional[str] = "fa", + add_legend: Optional[bool] = True, + max_cluster_radius: Optional[int] = 80, **kwargs, ): """Adds a marker cluster to the map. @@ -1530,13 +1531,20 @@ def add_points_from_xy( color_column (str, optional): The column name for the color values. Defaults to None. marker_colors (list, optional): A list of colors to be used for the markers. Defaults to None. icon_colors (list, optional): A list of colors to be used for the icons. Defaults to ['white']. - icon_names (list, optional): A list of names to be used for the icons. More icons can be found at https://fontawesome.com/v4/icons or https://getbootstrap.com/docs/3.3/components/?utm_source=pocket_mylist. Defaults to ['info']. + icon_names (list, optional): A list of names to be used for the icons. More icons can be found + at https://fontawesome.com/v4/icons or https://getbootstrap.com/docs/3.3/components/?utm_source=pocket_mylist. Defaults to ['info']. angle (int, optional): The angle of the icon. Defaults to 0. prefix (str, optional): The prefix states the source of the icon. 'fa' for font-awesome or 'glyphicon' for bootstrap 3. Defaults to 'fa'. add_legend (bool, optional): If True, a legend will be added to the map. Defaults to True. + max_cluster_radius (int, optional): The maximum radius that a cluster will cover from the central marker (in pixels). + **kwargs: Other keyword arguments to pass to folium.MarkerCluster(). For a list of available options, + see https://github.com/Leaflet/Leaflet.markercluster. For example, to change the cluster radius, use options={"maxClusterRadius": 50}. """ import pandas as pd + if "maxClusterRadius" not in kwargs: + kwargs["maxClusterRadius"] = max_cluster_radius + color_options = [ "red", "blue", @@ -1574,7 +1582,7 @@ def add_points_from_xy( ) if color_column is not None: - items = sorted(list(set(df[color_column]))) + items = list(set(df[color_column])) else: items = None @@ -1615,16 +1623,16 @@ def add_points_from_xy( if y not in col_names: raise ValueError(f"y must be one of the following: {', '.join(col_names)}") - marker_cluster = plugins.MarkerCluster(name=layer_name).add_to(self) + marker_cluster = plugins.MarkerCluster(name=layer_name, **kwargs).add_to(self) - for row in df.itertuples(): + for idx, row in df.iterrows(): html = "" for p in popup: - html = html + "" + p + "" + ": " + str(getattr(row, p)) + "
" + html = html + "" + p + "" + ": " + str(row[p]) + "
" popup_html = folium.Popup(html, min_width=min_width, max_width=max_width) if items is not None: - index = items.index(getattr(row, color_column)) + index = items.index(row[color_column]) marker_icon = folium.Icon( color=marker_colors[index], icon_color=icon_colors[index], @@ -1636,7 +1644,7 @@ def add_points_from_xy( marker_icon = None folium.Marker( - location=[getattr(row, y), getattr(row, x)], + location=[row[y], row[x]], popup=popup_html, icon=marker_icon, ).add_to(marker_cluster)