Пример #1
0
    def __init__(self, locations, popups=None, icons=None):
        super(MarkerCluster, self).__init__()
        self._name = 'MarkerCluster'

        if popups is None:
            popups = [None] * len(locations)
        if icons is None:
            icons = [None] * len(locations)

        for location, popup, icon in zip(locations, popups, icons):
            if popup is None or isinstance(popup, Popup):
                p = popup
            else:
                p = Popup(popup)
            if icon is None or isinstance(icon, Icon):
                i = icon
            else:
                i = Icon(icon)
            self.add_child(Marker(location, popup=p, icon=i))

        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.markerClusterGroup();
                {{this._parent.get_name()}}.addLayer({{this.get_name()}});
            {% endmacro %}
            """)
Пример #2
0
    def __init__(self,
                 locations=None,
                 popups=None,
                 icons=None,
                 name=None,
                 overlay=True,
                 control=True,
                 show=True,
                 icon_create_function=None,
                 options=None):
        super(MarkerCluster, self).__init__(name=name,
                                            overlay=overlay,
                                            control=control,
                                            show=show)
        self._name = 'MarkerCluster'

        if locations is not None:
            if popups is None:
                popups = [None] * len(locations)
            if icons is None:
                icons = [None] * len(locations)
            for location, popup, icon in zip(locations, popups, icons):
                p = popup if self._validate(popup, Popup) else Popup(popup)
                i = icon if self._validate(icon, Icon) else Icon(icon)
                self.add_child(Marker(location, popup=p, icon=i))

        options = {} if options is None else options
        self.options = json.dumps(options, sort_keys=True, indent=2)
        if icon_create_function is not None:
            assert isinstance(icon_create_function, str)
        self.icon_create_function = icon_create_function
Пример #3
0
    def __init__(self, locations=None, popups=None, icons=None, name=None,
                 overlay=True, control=True, show=True,
                 icon_create_function=None):
        super(MarkerCluster, self).__init__(name=name, overlay=overlay,
                                            control=control, show=show)

        if locations is not None:
            if popups is None:
                popups = [None]*len(locations)
            if icons is None:
                icons = [None]*len(locations)
            for location, popup, icon in zip(locations, popups, icons):
                p = popup if popup is None or isinstance(popup, Popup) else Popup(popup)  # noqa
                i = icon if icon is None or isinstance(icon, Icon) else Icon(icon)  # noqa
                self.add_child(Marker(location, popup=p, icon=i))

        self._name = 'MarkerCluster'
        self._icon_create_function = icon_create_function.strip() if icon_create_function else ''  # noqa
        self._template = Template(u"""
            {% macro script(this, kwargs) %}
            var {{this.get_name()}} = L.markerClusterGroup({
                {% if this._icon_create_function %}
                   iconCreateFunction: {{this._icon_create_function}}
                {% endif %}
            });
            {{this._parent.get_name()}}.addLayer({{this.get_name()}});
            {% endmacro %}
            """)
Пример #4
0
    def __init__(self,
                 locations=None,
                 popups=None,
                 icons=None,
                 name=None,
                 overlay=True,
                 control=True,
                 show=True,
                 icon_create_function=None):
        super(MarkerCluster, self).__init__(name=name,
                                            overlay=overlay,
                                            control=control,
                                            show=show)

        if locations is not None:
            if popups is None:
                popups = [None] * len(locations)
            if icons is None:
                icons = [None] * len(locations)
            for location, popup, icon in zip(locations, popups, icons):
                p = popup if popup is None or isinstance(
                    popup, Popup) else Popup(popup)  # noqa
                i = icon if icon is None or isinstance(icon, Icon) else Icon(
                    icon)  # noqa
                self.add_child(Marker(location, popup=p, icon=i))

        self._name = 'MarkerCluster'
        self._icon_create_function = icon_create_function.strip(
        ) if icon_create_function else ''  # noqa
Пример #5
0
    def __init__(self,
                 locations=None,
                 popups=None,
                 icons=None,
                 name=None,
                 overlay=True,
                 control=True,
                 show=True,
                 icon_create_function=None,
                 options=None,
                 **kwargs):
        if options is not None:
            kwargs.update(options)  # options argument is legacy
        super(MarkerCluster, self).__init__(name=name,
                                            overlay=overlay,
                                            control=control,
                                            show=show)
        self._name = 'MarkerCluster'

        if locations is not None:
            if popups is None:
                popups = [None] * len(locations)
            if icons is None:
                icons = [None] * len(locations)
            for location, popup, icon in zip(locations, popups, icons):
                p = popup if self._validate(popup, Popup) else Popup(popup)
                i = icon if self._validate(icon, Icon) else Icon(icon)
                self.add_child(Marker(location, popup=p, icon=i))

        self.options = parse_options(**kwargs)
        if icon_create_function is not None:
            assert isinstance(icon_create_function, str)
        self.icon_create_function = icon_create_function
Пример #6
0
    def __init__(self, locations, popups=None, icons=None):
        """Creates a MarkerCluster plugin to append into a map with
        Map.add_children.

        Parameters
        ----------
            locations: list of list or array of shape (n,2).
                Data points of the form [[lat, lng]].

            popups: list of length n.
                Popup for each marker.

            icons: list of length n.
                Icon for each marker.
        """
        super(MarkerCluster, self).__init__()
        self._name = 'MarkerCluster'

        if popups is None:
            popups = [None] * len(locations)
        if icons is None:
            icons = [None] * len(locations)

        for location, popup, icon in zip(locations, popups, icons):
            if popup is None or isinstance(popup, Popup):
                p = popup
            else:
                p = Popup(popup)
            if icon is None or isinstance(icon, Icon):
                i = icon
            else:
                i = Icon(icon)
            self.add_children(Marker(location, popup=p, icon=i))

        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.markerClusterGroup();
                {{this._parent.get_name()}}.addLayer({{this.get_name()}});
            {% endmacro %}
            """)
Пример #7
0
def test_icon_valid_marker_colors():
    assert len(Icon.color_options) == 19
    with pytest.warns(None) as record:
        for color in Icon.color_options:
            Icon(color=color)
    assert len(record) == 0
Пример #8
0
    search_data = '서울특별시 종로구 창신동 372-0번지'
    filtered_data = jibun_filter(search_data)

    coordinate_data = naver_api(filtered_data)

    result = coordinate_to_manhattan(coordinate_data,
                                     distance={
                                         'BUS': 0.002,
                                         'CROSSWALK': 0.001,
                                         'SUBWAY': 0.015,
                                         'POPULATION': 0.015
                                     })

    # Make a map using result data
    icon = {
        'station': Icon(color='red', icon='coffee', prefix='fa'),
        'crosswalk': Icon(color='purple'),
        'subway': Icon(color='orange'),
    }

    m = folium.Map([coordinate_data['lat'][0], coordinate_data['lng'][0]],
                   max_zoom=20,
                   min_zoom=12,
                   zoom_start=15,
                   tiles='OpenStreetMap')

    folium.Marker([coordinate_data['lat'][0],
                   coordinate_data['lng'][0]]).add_to(m)
    station_marker = MarkerCluster().add_to(m)
    crosswalk_marker = MarkerCluster().add_to(m)