Exemple #1
1
def test_polyline_popups():
    m = Map([43,-100], zoom_start=4)
    features.PolyLine([[40,-80],[45,-80]], popup="PolyLine").add_to(m)
    features.PolyLine([[40,-90],[45,-90]], popup=Popup("PolyLine")).add_to(m)
    features.MultiPolyLine([[[40,-110],[45,-110]]], popup="MultiPolyLine").add_to(m)
    features.MultiPolyLine([[[40,-120],[45,-120]]], popup=Popup("MultiPolyLine")).add_to(m)
    m._repr_html_()
def test_mulyipolyline():
    m = Map()

    locations = [[[45.51, -122.68], [37.77, -122.43], [34.04, -118.2]],
                 [[40.78, -73.91], [41.83, -87.62], [32.76, -96.72]]]

    multipolyline = PolyLine(locations=locations, popup='MultiPolyLine')
    multipolyline.add_to(m)

    expected_options = {
        'smoothFactor': 1.0,
        'noClip': False,
        'bubblingMouseEvents': True,
        'color': '#3388ff',
        'dashArray': None,
        'dashOffset': None,
        'fill': False,
        'fillColor': '#3388ff',
        'fillOpacity': 0.2,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1.0,
        'stroke': True,
        'weight': 3,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.polyline(
    {locations},
    {{
    "bubblingMouseEvents": true,
    "color": "#3388ff",
    "dashArray": null,
    "dashOffset": null,
    "fill": false,
    "fillColor": "#3388ff",
    "fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations,
               name=multipolyline.get_name(),
               map=m.get_name())

    rendered = multipolyline._template.module.script(multipolyline)
    assert normalize(rendered) == normalize(expected_rendered)
    assert multipolyline.get_bounds() == get_bounds(locations)
    assert json.dumps(multipolyline.to_dict()) == multipolyline.to_json()
    assert multipolyline.options == expected_options
Exemple #3
0
def test_rectangle():
    m = Map()

    location = [[45.6, -122.8], [45.61, -122.7]]
    rectangle = Rectangle(
        bounds=location,
        popup='I am a rectangle',
        color='black',
        weight=2,
        fill_opacity=0.6,
        opacity=1,
        fill=True,
        )
    rectangle.add_to(m)

    expected_options = {
        'bubblingMouseEvents': True,
        'color': 'black',
        'dashArray': None,
        'dashOffset': None,
        'fill': True,
        'fillColor': 'black',
        'fillOpacity': 0.6,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1,
        'stroke': True,
        'weight': 2,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.rectangle(
    {location},
    {{
    "bubblingMouseEvents": true,
    "color": "black",
    "dashArray": null,
    "dashOffset": null,
    "fill": true,
    "fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "opacity": 1,
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=rectangle.get_name(), location=location, map=m.get_name())

    rendered = rectangle._template.module.script(rectangle)
    assert rendered.strip().split() == expected_rendered.strip().split()
    assert rectangle.get_bounds() == location
    assert json.dumps(rectangle.to_dict()) == rectangle.to_json()
    assert rectangle.options == json.dumps(expected_options, sort_keys=True, indent=2)  # noqa
def test_polygon_marker():
    m = Map()
    locations = [[35.6636, 139.7634], [35.6629, 139.7664], [35.6663, 139.7706],
                 [35.6725, 139.7632], [35.6728, 139.7627], [35.6720, 139.7606],
                 [35.6682, 139.7588], [35.6663, 139.7627]]
    polygon = Polygon(locations=locations, popup='I am a polygon')
    polygon.add_to(m)

    expected_options = {
        'bubblingMouseEvents': True,
        'color': '#3388ff',
        'dashArray': None,
        'dashOffset': None,
        'fill': False,
        'fillColor': '#3388ff',
        'fillOpacity': 0.2,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'noClip': False,
        'opacity': 1.0,
        'smoothFactor': 1.0,
        'stroke': True,
        'weight': 3,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.polygon(
    {locations},
    {{
    "bubblingMouseEvents": true,
    "color": "#3388ff",
    "dashArray": null,
    "dashOffset": null,
    "fill": false,
    "fillColor": "#3388ff",
    "fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations, name=polygon.get_name(), map=m.get_name())

    rendered = polygon._template.module.script(polygon)
    assert _normalize(rendered) == _normalize(expected_rendered)
    assert polygon.get_bounds() == get_bounds(locations)
    assert json.dumps(polygon.to_dict()) == polygon.to_json()
    assert polygon.options == json.dumps(expected_options,
                                         sort_keys=True,
                                         indent=2)  # noqa
Exemple #5
0
def test_marker_popups():
    m = Map()
    features.Marker([45, -180], popup='-180').add_to(m)
    features.Marker([45, -120], popup=Popup('-120')).add_to(m)
    features.RegularPolygonMarker([45, -60], popup='-60').add_to(m)
    features.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
    features.CircleMarker([45, 60], popup='60').add_to(m)
    features.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
    m._repr_html_()
Exemple #6
0
def test_marker_popups():
    m = Map()
    features.Marker([45,-180],popup='-180').add_to(m)
    features.Marker([45,-120],popup=Popup('-120')).add_to(m)
    features.RegularPolygonMarker([45,-60],popup='-60').add_to(m)
    features.RegularPolygonMarker([45,0],popup=Popup('0')).add_to(m)
    features.CircleMarker([45,60],popup='60').add_to(m)
    features.CircleMarker([45,120],popup=Popup('120')).add_to(m)
    m._repr_html_()
Exemple #7
0
def test_mulyipolyline():
    m = Map()

    locations = [[[45.51, -122.68], [37.77, -122.43], [34.04, -118.2]],
                 [[40.78, -73.91], [41.83, -87.62], [32.76, -96.72]]]

    multipolyline = PolyLine(locations=locations, popup='MultiPolyLine')
    multipolyline.add_to(m)

    expected_options = {
        'smoothFactor': 1.0,
        'noClip': False,
        'bubblingMouseEvents': True,
        'color': '#3388ff',
        'dashArray': None,
        'dashOffset': None,
        'fill': False,
        'fillColor': '#3388ff',
        'fillOpacity': 0.2,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1.0,
        'stroke': True,
        'weight': 3,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.polyline(
    {locations},
    {{
    "bubblingMouseEvents": true,
    "color": "#3388ff",
    "dashArray": null,
    "dashOffset": null,
    "fill": false,
    "fillColor": "#3388ff",
    "fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations, name=multipolyline.get_name(), map=m.get_name())

    rendered = multipolyline._template.module.script(multipolyline)
    assert normalize(rendered) == normalize(expected_rendered)
    assert multipolyline.get_bounds() == get_bounds(locations)
    assert json.dumps(multipolyline.to_dict()) == multipolyline.to_json()
    assert multipolyline.options == expected_options
Exemple #8
0
def test_polyline_popups():
    m = Map([43, -100], zoom_start=4)
    features.PolyLine([[40, -80], [45, -80]], popup="PolyLine").add_to(m)
    features.PolyLine([[40, -90], [45, -90]],
                      popup=Popup("PolyLine")).add_to(m)
    features.MultiPolyLine([[[40, -110], [45, -110]]],
                           popup="MultiPolyLine").add_to(m)
    features.MultiPolyLine([[[40, -120], [45, -120]]],
                           popup=Popup("MultiPolyLine")).add_to(m)
    m._repr_html_()
Exemple #9
0
def test_color_line():
    m = Map([22.5, 22.5], zoom_start=3)
    color_line = folium.ColorLine([[0, 0], [0, 45], [45, 45], [45, 0], [0, 0]],
                                  [0, 1, 2, 3],
                                  colormap=['b', 'g', 'y', 'r'],
                                  nb_steps=4,
                                  weight=10,
                                  opacity=1)
    m.add_child(color_line)
    m._repr_html_()
Exemple #10
0
def test_wms_service():
    m = Map([40, -100], zoom_start=4)
    url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
    w = features.WmsTileLayer(url,
                              name='test',
                              format='image/png',
                              layers='nexrad-n0r-900913',
                              attr=u"Weather data © 2012 IEM Nexrad",
                              transparent=True)
    w.add_to(m)
    m._repr_html_()
Exemple #11
0
def test_polyline():
    m = Map()
    locations = [[40.0, -80.0], [45.0, -80.0]]
    polyline = PolyLine(locations=locations, popup='I am PolyLine')
    polyline.add_to(m)

    expected_options = {
        'smoothFactor': 1.0,
        'noClip': False,
        'bubblingMouseEvents': True,
        'color': '#3388ff',
        'dashArray': None,
        'dashOffset': None,
        'fill': False,
        'fillColor': '#3388ff',
        'fillOpacity': 0.2,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1.0,
        'stroke': True,
        'weight': 3,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.polyline(
    {locations},
    {{
    "bubblingMouseEvents": true,
    "color": "#3388ff",
    "dashArray": null,
    "dashOffset": null,
    "fill": false,
    "fillColor": "#3388ff",
    "fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations, name=polyline.get_name(), map=m.get_name())

    rendered = polyline._template.module.script(polyline)
    assert normalize(rendered) == normalize(expected_rendered)
    assert polyline.get_bounds() == get_bounds(locations)
    assert json.dumps(polyline.to_dict()) == polyline.to_json()
    assert polyline.options == expected_options
Exemple #12
0
def test_wms_service():
    m = Map([40, -100], zoom_start=4)
    url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
    w = features.WmsTileLayer(url,
                              name='test',
                              format='image/png',
                              layers='nexrad-n0r-900913',
                              attr=u"Weather data © 2012 IEM Nexrad",
                              transparent=True)
    w.add_to(m)
    m._repr_html_()
Exemple #13
0
def test_polyline():
    m = Map()
    locations = [[40, -80], [45, -80]]
    polyline = PolyLine(locations=locations, popup='I am PolyLine')
    polyline.add_to(m)

    expected_options = {
        'smoothFactor': 1.0,
        'noClip': False,
        'bubblingMouseEvents': True,
        'color': '#3388ff',
        'dashArray': None,
        'dashOffset': None,
        'fill': False,
        'fillColor': '#3388ff',
        'fillOpacity': 0.2,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1.0,
        'stroke': True,
        'weight': 3,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.polyline(
    {locations},
    {{
    "bubblingMouseEvents": true,
    "color": "#3388ff",
    "dashArray": null,
    "dashOffset": null,
    "fill": false,
    "fillColor": "#3388ff",
    "fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations, name=polyline.get_name(), map=m.get_name())

    rendered = polyline._template.module.script(polyline)
    assert rendered.strip().split() == expected_rendered.strip().split()
    assert polyline.get_bounds() == get_bounds(locations)
    assert json.dumps(polyline.to_dict()) == polyline.to_json()
    assert polyline.options == json.dumps(expected_options, sort_keys=True, indent=2)  # noqa
Exemple #14
0
def test_color_line():
    m = Map([22.5, 22.5], zoom_start=3)
    color_line = folium.ColorLine(
        [[0, 0], [0, 45], [45, 45], [45, 0], [0, 0]],
        [0, 1, 2, 3],
        colormap=['b', 'g', 'y', 'r'],
        nb_steps=4,
        weight=10,
        opacity=1)
    m.add_child(color_line)
    m._repr_html_()
Exemple #15
0
def test_marker_popups():
    m = Map()
    features.Marker([45, -180], popup="-180").add_to(m)
    features.Marker([45, -120], popup=Popup("-120")).add_to(m)
    features.RegularPolygonMarker([45, -60], popup="-60").add_to(m)
    features.RegularPolygonMarker([45, 0], popup=Popup("0")).add_to(m)
    features.CircleMarker([45, 60], popup="60").add_to(m)
    features.CircleMarker([45, 120], popup=Popup("120")).add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[45, -180], [45, 120]], bounds
Exemple #16
0
def test_marker_popups():
    m = Map()
    folium.Marker([45, -180], popup='-180').add_to(m)
    folium.Marker([45, -120], popup=Popup('-120')).add_to(m)
    folium.RegularPolygonMarker([45, -60], popup='-60').add_to(m)
    folium.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
    folium.CircleMarker([45, 60], popup='60').add_to(m)
    folium.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
    folium.CircleMarker([45, 90], popup=Popup('90'), weight=0).add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[45, -180], [45, 120]], bounds
Exemple #17
0
def test_marker_popups():
    m = Map()
    folium.Marker([45, -180], popup='-180').add_to(m)
    folium.Marker([45, -120], popup=Popup('-120')).add_to(m)
    folium.RegularPolygonMarker([45, -60], popup='-60').add_to(m)
    folium.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
    folium.CircleMarker([45, 60], popup='60').add_to(m)
    folium.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
    folium.CircleMarker([45, 90], popup=Popup('90'), weight=0).add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[45, -180], [45, 120]], bounds
Exemple #18
0
def test_polyline_popups():
    m = Map([43, -100], zoom_start=4)
    features.PolyLine([[40, -80], [45, -80]], popup='PolyLine').add_to(m)
    features.PolyLine([[40, -90], [45, -90]],
                      popup=Popup('PolyLine')).add_to(m)
    features.PolyLine([[[40, -110], [45, -110]]],
                      popup='MultiPolyLine').add_to(m)
    features.PolyLine([[[40, -120], [45, -120]]],
                      popup=Popup('MultiPolyLine')).add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[40, -120], [45, -80]], bounds
Exemple #19
0
def test_wms_service():
    m = Map([40, -100], zoom_start=4)
    url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
    w = folium.WmsTileLayer(url,
                            name='test',
                            fmt='image/png',
                            layers='nexrad-n0r-900913',
                            attr=u'Weather data © 2012 IEM Nexrad',
                            transparent=True)
    w.add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
Exemple #20
0
def test_wms_service():
    m = Map([40, -100], zoom_start=4)
    url = "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi"
    w = features.WmsTileLayer(
        url,
        name="test",
        format="image/png",
        layers="nexrad-n0r-900913",
        attr=u"Weather data © 2012 IEM Nexrad",
        transparent=True,
    )
    w.add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
Exemple #21
0
    def create_map(data):
        if not data:
            raise PreventUpdate

        df = pd.DataFrame(data)
        qtd_sem_latlon = df[["address_lat",
                             "address_lon"]].isna().max(axis=1).sum()
        df = df.dropna(subset=["address_lat", "address_lon"])

        map = Map(
            location=df[["address_lat", "address_lon"]].mean().values,
            height="89%",
            tiles=
            "https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png",
            attr="toner-bcg",
        )

        marker_cluster = MarkerCluster().add_to(map)

        for _, row in df.iterrows():
            Marker(
                location=[row["address_lat"], row["address_lon"]],
                popup=box(**row),
            ).add_to(marker_cluster)

        return f"{qtd_sem_latlon} imóveis sem latitude ou longitude", map._repr_html_(
        )
Exemple #22
0
def draw_map_once_function_call():
    # df = pd.read_csv("vac.csv")
    # df = pd.read_csv("vac210315.csv")
    # df = pd.read_csv("csv/vac210331.csv")
    df = pd.read_csv("csv/test.csv")

    m = Map(location=[36.5053542, 127.7043419], zoom_start=8)
    marker_cluster = MarkerCluster().add_to(m)
    addr_list = []
    for idx in range(len(df)):
        addr_list.append(df.loc[idx, "address"])

    # but one call func not multiple call
    # lon_list, lat_list = getLatLng_list(addr_list)

    for idx, addr in enumerate(addr_list):
        location_name = df.loc[idx, "location_name"]
        telephone = df.loc[idx, "telephone"]
        print(telephone)
        latitude = df.loc[idx, "latitude"]
        longitude = df.loc[idx, "longitude"]
        iframe = location_name + ":<br> " + addr + ": <br> " + telephone
        print(idx, ": ", iframe)
        popup = folium.Popup(iframe, min_width=200, max_width=200)
        Marker(location=[latitude, longitude],
               popup=popup,
               tooltip=location_name,
               icon=Icon(color='green', icon='flag')).add_to(marker_cluster)
    account_info = get_apikey("Account", "secret.json")
    return render_template(template_name_or_list="index.html",
                           map=m._repr_html_(),
                           account_info=account_info)
Exemple #23
0
def getMap():

    # initialize the map to the starting location and add starting location
    # this library will base location off user IP address. It works locally, but
    # not once the app is deployed (different IP address)
    g = geocoder.ip('me')
    start_coords = g.latlng
    themap = Map(location=start_coords, tiles="OpenStreetMap", zoom_start=15)
    folium.Marker(location=start_coords,
                  popup='Your Location',
                  icon=folium.Icon(color='red', icon='hi')).add_to(themap)

    # get nearby restaurant data
    startloc = str(start_coords[0]) + "," + str(start_coords[1])
    df = getRestaurantData(startloc)
    data = cleanDataframe(df)

    # add restaurants to the map
    for (y, x) in data.iterrows():
        loc = []
        loc.append(x['latitude'])
        loc.append(x['longitude'])
        color = "green"
        if (x['rating'] < 4.0):
            color = "orange"
        popup_text = "{}<br> Cuisine: {}<br> Average Rating: {}<br> Number of Reviews: {}"
        popup_text = popup_text.format(x["name"], x["descriptors"],
                                       x["rating"], x['review_count'])
        themap.add_child(
            Marker(location=loc,
                   popup=popup_text,
                   icon=folium.Icon(color=color)))
    return themap._repr_html_()
Exemple #24
0
    def as_map(self, img_name=None):

        if img_name == None:
            coord_index = self.meta_keys.index('GPS')
            coord_list = [
                self.metadata[key][coord_index][0:2] + [key]
                for key in self.metadata.keys()
            ]
            print(coord_list)

            cood_t = list(map(list, zip(*coord_list)))
            center = [(max(cood_t[0]) + min(cood_t[0])) / 2,
                      (max(cood_t[1]) + min(cood_t[1])) / 2]

            print(center)
            print(coord_list)

            img_map = Map(
                location=center,
                zoom_start=13,
                width='100%',
                height='100%',
                tiles='https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
                attr='Google')

            for x, y, img in coord_list:
                Marker(location=[x, y], popup='', tooltip=img).add_to(img_map)

            return (img_map._repr_html_())

        return ('')
def map_api_call():
    url = "https://api.odcloud.kr/api/15077586/v1/centers?page=1&perPage=300&serviceKey=" + get_apikey(
        "serviceKey", "secret.json")

    result = requests.get(url=url)
    json_result = json.loads(str(result.text))

    m = Map(location=[36.5053542, 127.7043419], zoom_start=8)
    marker_cluster = MarkerCluster().add_to(m)

    for idx in range(json_result["currentCount"]):
        address = json_result["data"][idx]["address"]
        centerName = json_result["data"][idx]["centerName"]
        facilityName = json_result["data"][idx]["facilityName"]
        lat = json_result["data"][idx]["lat"]
        lng = json_result["data"][idx]["lng"]
        iframe = centerName + ": <br> " + facilityName + ":<br> " + address
        popup = folium.Popup(iframe, min_width=200, max_width=200)
        Marker(location=[lat, lng],
               popup=popup,
               tooltip=centerName + " : " + facilityName,
               icon=Icon(color='green', icon='flag')).add_to(marker_cluster)
    account_info = get_apikey("Account", "secret.json")
    return render_template(template_name_or_list="index.html",
                           map=m._repr_html_(),
                           account_info=account_info)
Exemple #26
0
    def export_map(map_object: Map) -> str:
        """
        Export map as html string.

        :param map_object: (Map) bokeh figure object to export resources from.
        :return: (str) generated html for map.
        """
        return map_object._repr_html_()
def img_map(img_data):
    coord = [float(i) for i in img_data['Coord'].split(' , ')]
    map = Map(location=coord,
              zoom_start=10,
              width='100%',
              height='100%',
              tiles='https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
              attr='Google')

    Marker(coord).add_to(map)
    return (map._repr_html_())
Exemple #28
0
def generate_map(name_and_coordinates:dict):
    """
    generates map
    """
    mp = Map( zoom_start=15) 
    markers = FeatureGroup() 
    for screen_name in name_and_coordinates:
        markers.add_child(Marker(location=[name_and_coordinates[screen_name][0], name_and_coordinates[screen_name][1]], 
                                    popup=screen_name, 
                                    icon=Icon())) 
    mp.add_child(markers) 
    mp.add_child(LayerControl()) 
 
    return mp._repr_html_()
Exemple #29
0
def draw_map_multiple_function_call():
    # db연결
    dbcon = create_engine("mysql+pymysql://test:[email protected]/testdb")
    # df = pd.read_csv("vac.csv")
    # df = pd.read_csv("vac210315.csv")
    df = pd.read_csv("csv/vac210407.csv")
    # dataframe내 데이터를 db에 넣는다 테이블이 없으면 생성하고 테이블과 데이터가 있으면 삭제하고 다시 생성
    df.to_sql(name='vaccine_center', con=dbcon, if_exists='replace')
    # # row갯수 만큼 for문을 돌아서 row들의 데이터를 각각 저장한다 iterrows()

    m = Map(location=[36.5053542, 127.7043419], zoom_start=8)

    # print(df)
    for idx in range(len(df)):
        location_name = df.loc[idx, "location_name"]
        addr = df.loc[idx, "address"]
        addr_lon, addr_lat = getLatLng(addr)
        iframe = location_name + ":<br> " + addr
        popup = folium.Popup(iframe, min_width=200, max_width=200)
        Marker(location=[addr_lat, addr_lon],
               popup=popup,
               tooltip=location_name,
               icon=Icon(color='green', icon='flag')).add_to(m)
    return m._repr_html_()
Exemple #30
0
def test_circle_marker():
    m = Map()
    radius = 50
    popup = 'I am {} pixels'.format(radius)

    circle_marker = CircleMarker(
        location=[-27.55, -48.8],
        radius=radius,
        color='black',
        weight=2,
        fill_opacity=0.6,
        opacity=1,
        fill=True,
        popup=popup,
    )
    circle_marker.add_to(m)

    options = {
        'bubblingMouseEvents': True,
        'color': 'black',
        'dashArray': None,
        'dashOffset': None,
        'fill': True,
        'fillColor': 'black',
        'fillOpacity': 0.6,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1,
        'radius': 50,
        'stroke': True,
        'weight': 2,
    }

    m._repr_html_()
    expected_bounds = [[-27.55, -48.8], [-27.55, -48.8]]
    expected_rendered = """
    var {0} = L.circleMarker(
    [-27.55,-48.8],
    {{
    "bubblingMouseEvents": true,
    "color": "black",
    "dashArray": null,
    "dashOffset": null,
    "fill": true,
    "fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "opacity": 1,
    "radius": 50,
    "stroke": true,
    "weight": 2
    }}
    ).addTo({1});
    """.format(circle_marker.get_name(), m.get_name())

    rendered = circle_marker._template.module.script(circle_marker)
    assert rendered.strip().split() == expected_rendered.strip().split()
    assert circle_marker.get_bounds() == expected_bounds
    assert json.dumps(circle_marker.to_dict()) == circle_marker.to_json()
    assert circle_marker.location == [-27.55, -48.8]
    assert circle_marker.options == json.dumps(options,
                                               sort_keys=True,
                                               indent=2)
Exemple #31
0
def test_custom_legend():
    m = Map([22.5, 22.5], zoom_start=3)
    features.CustomLegend(content="This is a test case", position="topright", style="padding: 6px 8px;font: 14px/16px Arial, Helvetica, sans-serif;box-shadow: 0 0 15px;background: white;border-radius: 5px").add_to(m)
    m._repr_html_()
Exemple #32
0
def test_multi_option_circle_marker():
    m = Map([43, -100], zoom_start=4)
    features.CustomLegend(content="This is a test case", position="topright", style="padding: 6px 8px;font: 14px/16px Arial, Helvetica, sans-serif;box-shadow: 0 0 15px;background: white;border-radius: 5px").add_to(m)
    features.CustomCircleMarker([40, -80], radius=100, color="green", fill_color="black", fill_opacity=0.6, clickUrl="www.example.com", boxtxt="And it works..").add_to(m)
    
    m._repr_html_()
Exemple #33
0
def test_rectangle():
    m = Map()

    location = [[45.6, -122.8], [45.61, -122.7]]
    rectangle = Rectangle(
        bounds=location,
        popup='I am a rectangle',
        color='black',
        weight=2,
        fill_opacity=0.6,
        opacity=1,
        fill=True,
        )
    rectangle.add_to(m)

    expected_options = {
        'bubblingMouseEvents': True,
        'color': 'black',
        'dashArray': None,
        'dashOffset': None,
        'fill': True,
        'fillColor': 'black',
        'fillOpacity': 0.6,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'noClip': False,
        'opacity': 1,
        'smoothFactor': 1.0,
        'stroke': True,
        'weight': 2,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.rectangle(
    {location},
    {{
    "bubblingMouseEvents": true,
    "color": "black",
    "dashArray": null,
    "dashOffset": null,
    "fill": true,
    "fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=rectangle.get_name(), location=location, map=m.get_name())

    rendered = rectangle._template.module.script(rectangle)
    assert normalize(rendered) == normalize(expected_rendered)
    assert rectangle.get_bounds() == location
    assert json.dumps(rectangle.to_dict()) == rectangle.to_json()
    assert rectangle.options == expected_options
Exemple #34
0
def test_circle():
    m = Map()
    radius = 10000
    popup = 'I am {} meters'.format(radius)
    location = [-27.551667, -48.478889]

    circle = Circle(
        location=location,
        radius=radius,
        color='black',
        weight=2,
        fill_opacity=0.6,
        opacity=1,
        fill=True,
        popup=popup,
    )
    circle.add_to(m)

    expected_options = {
        'bubblingMouseEvents': True,
        'color': 'black',
        'dashArray': None,
        'dashOffset': None,
        'fill': True,
        'fillColor': 'black',
        'fillOpacity': 0.6,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1,
        'radius': radius,
        'stroke': True,
        'weight': 2,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.circle(
    {location},
    {{
    "bubblingMouseEvents": true,
    "color": "black",
    "dashArray": null,
    "dashOffset": null,
    "fill": true,
    "fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "opacity": 1,
    "radius": {radius},
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=circle.get_name(), location=location, radius=radius, map=m.get_name())  # noqa

    rendered = circle._template.module.script(circle)
    assert rendered.strip().split() == expected_rendered.strip().split()
    assert circle.get_bounds() == [location, location]
    assert json.dumps(circle.to_dict()) == circle.to_json()
    assert circle.location == [-27.551667, -48.478889]
    assert circle.options == json.dumps(expected_options, sort_keys=True, indent=2)  # noqa
Exemple #35
0
def test_polygon_marker():
    m = Map()
    locations = [[35.6636, 139.7634],
                 [35.6629, 139.7664],
                 [35.6663, 139.7706],
                 [35.6725, 139.7632],
                 [35.6728, 139.7627],
                 [35.6720, 139.7606],
                 [35.6682, 139.7588],
                 [35.6663, 139.7627]]
    polygon = Polygon(locations=locations, popup='I am a polygon')
    polygon.add_to(m)

    expected_options = {
        'bubblingMouseEvents': True,
        'color': '#3388ff',
        'dashArray': None,
        'dashOffset': None,
        'fill': False,
        'fillColor': '#3388ff',
        'fillOpacity': 0.2,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'noClip': False,
        'opacity': 1.0,
        'smoothFactor': 1.0,
        'stroke': True,
        'weight': 3,
    }

    m._repr_html_()
    expected_rendered = """
    var {name} = L.polygon(
    {locations},
    {{
    "bubblingMouseEvents": true,
    "color": "#3388ff",
    "dashArray": null,
    "dashOffset": null,
    "fill": false,
    "fillColor": "#3388ff",
    "fillOpacity": 0.2,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "noClip": false,
    "opacity": 1.0,
    "smoothFactor": 1.0,
    "stroke": true,
    "weight": 3
    }}
    )
    .addTo({map});
    """.format(locations=locations, name=polygon.get_name(), map=m.get_name())

    rendered = polygon._template.module.script(polygon)
    assert normalize(rendered) == normalize(expected_rendered)
    assert polygon.get_bounds() == get_bounds(locations)
    assert json.dumps(polygon.to_dict()) == polygon.to_json()
    assert polygon.options == expected_options
def test_circle_marker():
    m = Map()
    radius = 50
    popup = 'I am {} pixels'.format(radius)
    location = [-27.55, -48.8]

    circle_marker = CircleMarker(
        location=location,
        radius=radius,
        color='black',
        weight=2,
        fill_opacity=0.6,
        opacity=1,
        fill=True,
        popup=popup,
    )
    circle_marker.add_to(m)

    options = {
        'bubblingMouseEvents': True,
        'color': 'black',
        'dashArray': None,
        'dashOffset': None,
        'fill': True,
        'fillColor': 'black',
        'fillOpacity': 0.6,
        'fillRule': 'evenodd',
        'lineCap': 'round',
        'lineJoin': 'round',
        'opacity': 1,
        'radius': radius,
        'stroke': True,
        'weight': 2,
    }

    m._repr_html_()
    expected_bounds = [location, location]
    expected_rendered = """
    var {name} = L.circleMarker(
    {location},
    {{
    "bubblingMouseEvents": true,
    "color": "black",
    "dashArray": null,
    "dashOffset": null,
    "fill": true,
    "fillColor": "black",
    "fillOpacity": 0.6,
    "fillRule": "evenodd",
    "lineCap": "round",
    "lineJoin": "round",
    "opacity": 1,
    "radius": {radius},
    "stroke": true,
    "weight": 2
    }}
    )
    .addTo({map});
    """.format(name=circle_marker.get_name(), location=location, radius=radius, map=m.get_name())  # noqa

    rendered = circle_marker._template.module.script(circle_marker)
    assert normalize(rendered) == normalize(expected_rendered)
    assert circle_marker.get_bounds() == expected_bounds
    assert json.dumps(circle_marker.to_dict()) == circle_marker.to_json()
    assert circle_marker.location == location
    assert circle_marker.options == options