示例#1
0
    def __init__(self, icon_image, icon_size=None, icon_anchor=None,
                 shadow_image=None, shadow_size=None, shadow_anchor=None,
                 popup_anchor=None):
        super(Icon, self).__init__()
        self._name = 'CustomIcon'
        self.icon_url = image_to_url(icon_image)
        self.icon_size = icon_size
        self.icon_anchor = icon_anchor

        self.shadow_url = (image_to_url(shadow_image)
                           if shadow_image is not None else None)
        self.shadow_size = shadow_size
        self.shadow_anchor = shadow_anchor
        self.popup_anchor = popup_anchor
示例#2
0
    def __init__(self, image, bounds, origin='upper', colormap=None,
                 mercator_project=False, pixelated=True,
                 name=None, overlay=True, control=True, show=True, **kwargs):
        super(ImageOverlay, self).__init__(name=name, overlay=overlay,
                                           control=control, show=show)

        options = {
            'opacity': kwargs.pop('opacity', 1.),
            'alt': kwargs.pop('alt', ''),
            'interactive': kwargs.pop('interactive', False),
            'crossOrigin': kwargs.pop('cross_origin', False),
            'errorOverlayUrl': kwargs.pop('error_overlay_url', ''),
            'zIndex': kwargs.pop('zindex', 1),
            'className': kwargs.pop('class_name', ''),
        }
        self._name = 'ImageOverlay'
        self.pixelated = pixelated

        if mercator_project:
            image = mercator_transform(
                image,
                [bounds[0][0],
                 bounds[1][0]],
                origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)

        self.bounds = json.loads(json.dumps(bounds))
        self.options = json.dumps(options, sort_keys=True, indent=2)
    def __init__(self,
                 image,
                 bounds,
                 origin='upper',
                 colormap=None,
                 mercator_project=False,
                 pixelated=True,
                 name=None,
                 overlay=True,
                 control=True,
                 show=True,
                 **kwargs):
        super(ImageOverlay, self).__init__(name=name,
                                           overlay=overlay,
                                           control=control,
                                           show=show)
        self._name = 'ImageOverlay'
        self.bounds = bounds
        self.options = parse_options(**kwargs)
        self.pixelated = pixelated
        if mercator_project:
            image = mercator_transform(image, [bounds[0][0], bounds[1][0]],
                                       origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)
示例#4
0
    def __init__(self, image, bounds, origin='upper', colormap=None,
                 mercator_project=False, pixelated=True,
                 name=None, overlay=True, control=True, show=True, **kwargs):
        super(ImageOverlay, self).__init__(name=name, overlay=overlay,
                                           control=control, show=show)

        options = {
            'opacity': kwargs.pop('opacity', 1.),
            'alt': kwargs.pop('alt', ''),
            'interactive': kwargs.pop('interactive', False),
            'crossOrigin': kwargs.pop('cross_origin', False),
            'errorOverlayUrl': kwargs.pop('error_overlay_url', ''),
            'zIndex': kwargs.pop('zindex', 1),
            'className': kwargs.pop('class_name', ''),
        }
        self._name = 'ImageOverlay'
        self.pixelated = pixelated

        if mercator_project:
            image = mercator_transform(
                image,
                [bounds[0][0],
                 bounds[1][0]],
                origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)

        self.bounds = json.loads(json.dumps(bounds))
        self.options = json.dumps(options, sort_keys=True, indent=2)
示例#5
0
    def __init__(self,
                 image,
                 bounds,
                 origin='upper',
                 colormap=None,
                 mercator_project=False,
                 pixelated=True,
                 name=None,
                 overlay=True,
                 control=True,
                 show=True,
                 **kwargs):
        super(ImageOverlay, self).__init__(name=name,
                                           overlay=overlay,
                                           control=control,
                                           show=show)

        options = {
            'opacity': kwargs.pop('opacity', 1.),
            'alt': kwargs.pop('alt', ''),
            'interactive': kwargs.pop('interactive', False),
            'crossOrigin': kwargs.pop('cross_origin', False),
            'errorOverlayUrl': kwargs.pop('error_overlay_url', ''),
            'zIndex': kwargs.pop('zindex', 1),
            'className': kwargs.pop('class_name', ''),
        }
        self._name = 'ImageOverlay'
        self.pixelated = pixelated

        if mercator_project:
            image = mercator_transform(image, [bounds[0][0], bounds[1][0]],
                                       origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)

        self.bounds = json.loads(json.dumps(bounds))
        self.options = json.dumps(options, sort_keys=True, indent=2)
        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.imageOverlay(
                    '{{ this.url }}',
                    {{ this.bounds }},
                    {{ this.options }}
                    ).addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)
示例#6
0
    def __init__(self, image, bounds, origin='upper', colormap=None,
                 mercator_project=False, pixelated=True,
                 name=None, overlay=True, control=True, show=True, **kwargs):
        super(ImageOverlay, self).__init__(name=name, overlay=overlay,
                                           control=control, show=show)
        self._name = 'ImageOverlay'
        self.bounds = bounds
        self.options = parse_options(**kwargs)
        self.pixelated = pixelated
        if mercator_project:
            image = mercator_transform(
                image,
                [bounds[0][0], bounds[1][0]],
                origin=origin
            )

        self.url = image_to_url(image, origin=origin, colormap=colormap)
示例#7
0
    def __init__(self, image, bounds, origin='upper', colormap=None,
                 mercator_project=False, pixelated=True,
                 name=None, overlay=True, control=True, show=True, **kwargs):
        super(ImageOverlay, self).__init__(name=name, overlay=overlay,
                                           control=control, show=show)

        options = {
            'opacity': kwargs.pop('opacity', 1.),
            'alt': kwargs.pop('alt', ''),
            'interactive': kwargs.pop('interactive', False),
            'crossOrigin': kwargs.pop('cross_origin', False),
            'errorOverlayUrl': kwargs.pop('error_overlay_url', ''),
            'zIndex': kwargs.pop('zindex', 1),
            'className': kwargs.pop('class_name', ''),
        }
        self._name = 'ImageOverlay'
        self.pixelated = pixelated

        if mercator_project:
            image = mercator_transform(
                image,
                [bounds[0][0],
                 bounds[1][0]],
                origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)

        self.bounds = json.loads(json.dumps(bounds))
        self.options = json.dumps(options, sort_keys=True, indent=2)
        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.imageOverlay(
                    '{{ this.url }}',
                    {{ this.bounds }},
                    {{ this.options }}
                    ).addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)
示例#8
0
    def __init__(self, image, bounds, opacity=1., attr=None,
                 origin='upper', colormap=None, mercator_project=False,
                overlay=True, control=True):
        """
        Used to load and display a single image over specific bounds of
        the map, implements ILayer interface.

        Parameters
        ----------
        image: string, file or array-like object
            The data you want to draw on the map.
            * If string, it will be written directly in the output file.
            * If file, it's content will be converted as embedded in the
              output file.
            * If array-like, it will be converted to PNG base64 string
              and embedded in the output.
        bounds: list
            Image bounds on the map in the form [[lat_min, lon_min],
            [lat_max, lon_max]]
        opacity: float, default Leaflet's default (1.0)
        attr: string, default Leaflet's default ("")
        origin : ['upper' | 'lower'], optional, default 'upper'
            Place the [0,0] index of the array in the upper left or
            lower left corner of the axes.
        colormap : callable, used only for `mono` image.
            Function of the form [x -> (r,g,b)] or [x -> (r,g,b,a)]
            for transforming a mono image into RGB.
            It must output iterables of length 3 or 4,
            with values between 0 and 1.
            Hint : you can use colormaps from `matplotlib.cm`.
        mercator_project : bool, default False.
            Used only for array-like image.  Transforms the data to
            project (longitude, latitude) coordinates to the
            Mercator projection.
            Beware that this will only work if `image` is an array-like
            object.
        """
        super(ImageOverlay, self).__init__(overlay=overlay, control=control)
        self._name = 'ImageOverlay'
        self.overlay = overlay

        if mercator_project:
            image = mercator_transform(image,
                                       [bounds[0][0], bounds[1][0]],
                                       origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)

        self.bounds = json.loads(json.dumps(bounds))
        options = {
            'opacity': opacity,
            'attribution': attr,
        }
        self.options = json.dumps({key: val for key, val
                                   in options.items() if val},
                                  sort_keys=True)
        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.imageOverlay(
                    '{{ this.url }}',
                    {{ this.bounds }},
                    {{ this.options }}
                    ).addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)
示例#9
0
    def __init__(self,
                 image,
                 bounds,
                 opacity=1.,
                 attr=None,
                 origin='upper',
                 colormap=None,
                 mercator_project=False,
                 overlay=True,
                 control=True):
        """
        Used to load and display a single image over specific bounds of
        the map, implements ILayer interface.

        Parameters
        ----------
        image: string, file or array-like object
            The data you want to draw on the map.
            * If string, it will be written directly in the output file.
            * If file, it's content will be converted as embedded in the
              output file.
            * If array-like, it will be converted to PNG base64 string
              and embedded in the output.
        bounds: list
            Image bounds on the map in the form [[lat_min, lon_min],
            [lat_max, lon_max]]
        opacity: float, default Leaflet's default (1.0)
        attr: string, default Leaflet's default ("")
        origin : ['upper' | 'lower'], optional, default 'upper'
            Place the [0,0] index of the array in the upper left or
            lower left corner of the axes.
        colormap : callable, used only for `mono` image.
            Function of the form [x -> (r,g,b)] or [x -> (r,g,b,a)]
            for transforming a mono image into RGB.
            It must output iterables of length 3 or 4,
            with values between 0 and 1.
            Hint : you can use colormaps from `matplotlib.cm`.
        mercator_project : bool, default False.
            Used only for array-like image.  Transforms the data to
            project (longitude, latitude) coordinates to the
            Mercator projection.
            Beware that this will only work if `image` is an array-like
            object.

        """
        super(ImageOverlay, self).__init__(overlay=overlay, control=control)
        self._name = 'ImageOverlay'
        self.overlay = overlay

        if mercator_project:
            image = mercator_transform(image, [bounds[0][0], bounds[1][0]],
                                       origin=origin)

        self.url = image_to_url(image, origin=origin, colormap=colormap)

        self.bounds = json.loads(json.dumps(bounds))
        options = {
            'opacity': opacity,
            'attribution': attr,
        }
        self.options = json.dumps(
            {key: val
             for key, val in options.items() if val}, sort_keys=True)
        self._template = Template(u"""
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.imageOverlay(
                    '{{ this.url }}',
                    {{ this.bounds }},
                    {{ this.options }}
                    ).addTo({{this._parent.get_name()}});
            {% endmacro %}
            """)