Exemple #1
0
    def __init__(self,
                 location,
                 radius=10,
                 popup=None,
                 tooltip=None,
                 **kwargs):
        super(Circle, self).__init__(location=location, popup=popup)
        self._name = 'circle'
        self.tooltip = tooltip

        options = _parse_path(**kwargs)
        options.update({'radius': radius})
        self.options = json.dumps(options, sort_keys=True, indent=2)

        self._template = Template(u"""
            {% macro script(this, kwargs) %}

            var {{this.get_name()}} = L.circle(
                [{{this.location[0]}}, {{this.location[1]}}],
                {{ this.options }}
                )
                {% if this.tooltip %}.bindTooltip("{{this.tooltip.__str__()}}"){% endif %}
                .addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)
    def __init__(self, location, radius=10, popup=None, **kw):
        super(CircleMarker, self).__init__(location=location, popup=popup)
        self._name = 'CircleMarker'
        options = _parse_path(**kw)

        options.update({'radius': radius})
        self.options = json.dumps(options, sort_keys=True, indent=2)

        self._template = Template(u"""
            {% macro script(this, kwargs) %}
            var {{this.get_name()}} = L.circleMarker(
                [{{this.location[0]}},{{this.location[1]}}],
                {{ this.options }}
                ).addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)
    def __init__(self, locations, popup=None, **kw):
        super(PolyLine, self).__init__(location=locations, popup=popup)
        self._name = 'PolyLine'
        options = _parse_path(**kw)
        options.update({
            'smoothFactor': kw.pop('smooth_factor', 1.0),
            'noClip': kw.pop('no_clip', False),
        })

        self.options = json.dumps(options, sort_keys=True, indent=2)

        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.polyline(
                    {{this.location}},
                    {{ this.options }}).addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)  # noqa
Exemple #4
0
    def __init__(self, locations, popup=None, tooltip=None, **kwargs):
        super(Polygon, self).__init__(locations, popup=popup)
        self._name = 'Polygon'
        self.tooltip = tooltip

        options = _parse_path(**kwargs)
        self.options = json.dumps(options, sort_keys=True, indent=2)

        self._template = Template(u"""
            {% macro script(this, kwargs) %}

            var {{this.get_name()}} = L.polygon(
                {{this.location}},
                {{ this.options }}
                )
                {% if this.tooltip %}.bindTooltip("{{this.tooltip.__str__()}}"){% endif %}
                .addTo({{this._parent.get_name()}});

            {% endmacro %}
            """)