コード例 #1
0
def mapper(df):
    # Initialize the map
    m = folium.Map(location=[df.mean()["FAC_LAT"], df.mean()["FAC_LONG"]])

    # Create the Marker Cluster array
    #kwargs={"disableClusteringAtZoom": 10, "showCoverageOnHover": False}
    mc = FastMarkerCluster("")

    # Add a clickable marker for each facility
    for index, row in df.iterrows():
        mc.add_child(
            folium.CircleMarker(
                location=[row["FAC_LAT"], row["FAC_LONG"]],
                popup=row["FAC_NAME"] + "<p><a href='" + row["DFR_URL"] +
                "' target='_blank'>Link to ECHO detailed report</a></p>",
                radius=8,
                color="black",
                weight=1,
                fill_color="orange",
                fill_opacity=.4))

    m.add_child(mc)
    bounds = m.get_bounds()
    m.fit_bounds(bounds)

    # Show the map
    return m
コード例 #2
0
ファイル: utilities.py プロジェクト: shansen5/CA_Prisons
def mapper(df, is_echo=True):
    # Initialize the map
    m = folium.Map(location=[df.mean()["FAC_LAT"], df.mean()["FAC_LONG"]])

    # Create the Marker Cluster array
    #kwargs={"disableClusteringAtZoom": 10, "showCoverageOnHover": False}
    mc = FastMarkerCluster("")

    # Add a clickable marker for each facility
    for index, row in df.iterrows():
        mc.add_child(
            folium.CircleMarker(location=[row["FAC_LAT"], row["FAC_LONG"]],
                                popup=marker_text(row, is_echo),
                                radius=8,
                                color="black",
                                weight=1,
                                fill_color="orange",
                                fill_opacity=.4))

    m.add_child(mc)
    bounds = m.get_bounds()
    m.fit_bounds(bounds)

    # Show the map
    return m
コード例 #3
0
def mapper(df, bounds=None, no_text=False):
    '''
    Display a map of the Dataframe passed in.
    Based on https://medium.com/@bobhaffner/folium-markerclusters-and-fastmarkerclusters-1e03b01cb7b1

    Parameters
    ----------
    df : Dataframe
        The facilities to map.  They must have a FAC_LAT and FAC_LONG field.
    bounds : Dataframe
        A bounding rectangle--minx, miny, maxx, maxy.  Discard points outside.

    Returns
    -------
    folium.Map
    '''

    # Initialize the map
    m = folium.Map(location=[df.mean()["FAC_LAT"], df.mean()["FAC_LONG"]])

    # Create the Marker Cluster array
    #kwargs={"disableClusteringAtZoom": 10, "showCoverageOnHover": False}
    mc = FastMarkerCluster("")

    # Add a clickable marker for each facility
    for index, row in df.iterrows():
        if (bounds is not None):
            if (not check_bounds(row, bounds)):
                continue
        mc.add_child(
            folium.CircleMarker(location=[row["FAC_LAT"], row["FAC_LONG"]],
                                popup=marker_text(row, no_text),
                                radius=8,
                                color="black",
                                weight=1,
                                fill_color="orange",
                                fill_opacity=.4))

    m.add_child(mc)
    bounds = m.get_bounds()
    m.fit_bounds(bounds)

    # Show the map
    return m