Exemple #1
0
 def __init__(self,
              data,
              transition_time=200,
              loop=False,
              auto_play=False,
              period='P1D',
              time_interval=False,
              name=None):
     super(TimestampedWmsTileLayers, self).__init__(name=name,
                                                    overlay=True,
                                                    control=False,
                                                    show=True)
     self._name = 'TimestampedWmsTileLayers'
     self.options = parse_options(
         period=period,
         time_interval=time_interval,
     )
     self.options_control = parse_options(
         position='bottomleft',
         auto_play=auto_play,
         player_options={
             'transitionTime': int(transition_time),
             'loop': loop,
         },
     )
     if isinstance(data, WmsTileLayer):
         self.layers = [data]
     else:
         self.layers = data  # Assume iterable
Exemple #2
0
 def __init__(self,
              width=20,
              height=20,
              radius=12,
              weight=2.0,
              color="#3388ff",
              fill_color="#3388ff",
              opacity=0.75,
              fill_opacity=0.5):
     super(CirclePattern, self).__init__()
     self._name = 'CirclePattern'
     self.options_pattern_circle = parse_options(
         x=radius + 2 * weight,
         y=radius + 2 * weight,
         weight=weight,
         radius=radius,
         color=color,
         fill_color=fill_color,
         opacity=opacity,
         fill_opacity=fill_opacity,
         fill=True,
     )
     self.options_pattern = parse_options(
         width=width,
         height=height,
     )
     self.parent_map = None
Exemple #3
0
 def __init__(self,
              collapsed=True,
              expand="touch",
              position="topright",
              placeholder="Search...",
              errorMessage="Nothing found",
              iconLabel="Initiate a new search",
              showUniqueResult=True,
              showResultIcons=False,
              suggestMinLength=3,
              suggestTimeout=250,
              query="",
              queryMinLength=1,
              defaultMarkGeocode=True,
              **kwargs):
     super(LocateGeocoder, self).__init__()
     self._name = 'LocateGeocoder'
     self.options = parse_options(collapsed=collapsed,
                                  expand=expand,
                                  position=position,
                                  placeholder=placeholder,
                                  errorMessage=errorMessage,
                                  iconLabel=iconLabel,
                                  showUniqueResult=showUniqueResult,
                                  showResultIcons=showResultIcons,
                                  suggestMinLength=suggestMinLength,
                                  suggestTimeout=suggestTimeout,
                                  query=query,
                                  queryMinLength=queryMinLength,
                                  defaultMarkGeocode=defaultMarkGeocode,
                                  **kwargs)
    def __init__(self,
                 icon=None,
                 icon_shape=None,
                 border_width=3,
                 border_color='#000',
                 text_color='#000',
                 background_color='#FFF',
                 inner_icon_style='',
                 spin=False,
                 number=None,
                 **kwargs):
        super(BeautifyIcon, self).__init__()
        self._name = 'BeautifyIcon'

        self.options = parse_options(icon=icon,
                                     icon_shape=icon_shape,
                                     border_width=border_width,
                                     border_color=border_color,
                                     text_color=text_color,
                                     background_color=background_color,
                                     inner_icon_style=inner_icon_style,
                                     spin=spin,
                                     isAlphaNumericIcon=number is not None,
                                     text=number,
                                     **kwargs)
    def __init__(self, data, transition_time=200, loop=True, auto_play=True,
                 add_last_point=True, period='P1D', min_speed=0.1, max_speed=10,
                 loop_button=False, date_options='YYYY-MM-DD HH:mm:ss',
                 time_slider_drag_update=False, duration=None):
        super(TimestampedGeoJson, self).__init__()
        self._name = 'TimestampedGeoJson'

        if 'read' in dir(data):
            self.embed = True
            self.data = data.read()
        elif type(data) is dict:
            self.embed = True
            self.data = json.dumps(data)
        else:
            self.embed = False
            self.data = data
        self.add_last_point = bool(add_last_point)
        self.period = period
        self.date_options = date_options
        self.duration = 'undefined' if duration is None else '"' + duration + '"'

        self.options = parse_options(
            position='bottomleft',
            min_speed=min_speed,
            max_speed=max_speed,
            auto_play=auto_play,
            loop_button=loop_button,
            time_slider_drag_update=time_slider_drag_update,
            player_options={
                'transitionTime': int(transition_time),
                'loop': loop,
                'startOver': True
            },
        )
Exemple #6
0
    def __init__(self, tile_layer=None, position='bottomright', width=150,
                 height=150, collapsed_width=25, collapsed_height=25,
                 zoom_level_offset=-5, zoom_level_fixed=None,
                 center_fixed=False, zoom_animation=False,
                 toggle_display=False, auto_toggle_display=False,
                 minimized=False, **kwargs):

        super(MiniMap, self).__init__()
        self._name = 'MiniMap'

        if tile_layer is None:
            self.tile_layer = TileLayer()
        elif isinstance(tile_layer, TileLayer):
            self.tile_layer = tile_layer
        else:
            self.tile_layer = TileLayer(tile_layer)

        self.options = parse_options(
            position=position,
            width=width,
            height=height,
            collapsed_width=collapsed_width,
            collapsed_height=collapsed_height,
            zoom_level_offset=zoom_level_offset,
            zoom_level_fixed=zoom_level_fixed,
            center_fixed=center_fixed,
            zoom_animation=zoom_animation,
            toggle_display=toggle_display,
            auto_toggle_display=auto_toggle_display,
            minimized=minimized,
            **kwargs
        )
Exemple #7
0
 def __init__(self, name=None, overlay=True, control=True, show=True,
              **kwargs):
     super(FeatureGroup, self).__init__(name=name, overlay=overlay,
                                        control=control, show=show)
     self._name = 'FeatureGroup'
     self.tile_name = name if name is not None else self.get_name()
     self.options = parse_options(**kwargs)
Exemple #8
0
    def __init__(self, html=None, parse_html=False, max_width='100%',
                 show=False, sticky=False, **kwargs):
        super(Popup, self).__init__()
        self._name = 'Popup'
        self.header = Element()
        self.html = Element()
        self.script = Element()

        self.header._parent = self
        self.html._parent = self
        self.script._parent = self

        script = not parse_html

        if isinstance(html, Element):
            self.html.add_child(html)
        elif isinstance(html, str):
            self.html.add_child(Html(html, script=script))

        self.show = show
        self.options = parse_options(
            max_width=max_width,
            autoClose=False if show or sticky else None,
            closeOnClick=False if sticky else None,
            **kwargs
        )
    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
    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)
    def __init__(self,
                 location,
                 radius,
                 direction=None,
                 arc=None,
                 start_angle=None,
                 stop_angle=None,
                 popup=None,
                 tooltip=None,
                 **kwargs):
        super(SemiCircle, self).__init__(location,
                                         popup=popup,
                                         tooltip=tooltip)
        self._name = 'SemiCircle'
        self.direction = (
            direction,
            arc) if direction is not None and arc is not None else None
        self.options = path_options(line=False, radius=radius, **kwargs)
        self.options.update(
            parse_options(
                start_angle=start_angle,
                stop_angle=stop_angle,
            ))

        if not ((direction is None and arc is None) and
                (start_angle is not None and stop_angle is not None) or
                (direction is not None and arc is not None) and
                (start_angle is None and stop_angle is None)):
            raise ValueError(
                "Invalid arguments. Either provide direction and arc OR start_angle and stop_angle"
            )
    def __init__(self,
                 tiles='OpenStreetMap',
                 min_zoom=0,
                 max_zoom=18,
                 max_native_zoom=None,
                 attr=None,
                 detect_retina=False,
                 name=None,
                 overlay=False,
                 control=True,
                 show=True,
                 no_wrap=False,
                 subdomains='abc',
                 tms=False,
                 opacity=1,
                 **kwargs):

        self.tile_name = (name if name is not None else ''.join(
            tiles.lower().strip().split()))
        super(TileLayer, self).__init__(name=self.tile_name,
                                        overlay=overlay,
                                        control=control,
                                        show=show)
        self._name = 'TileLayer'
        self._env = ENV

        tiles_flat = ''.join(tiles.lower().strip().split())
        if tiles_flat in {
                'cloudmade', 'mapbox', 'mapboxbright', 'mapboxcontrolroom'
        }:
            # added in May 2020 after v0.11.0, remove in a future release
            raise ValueError(
                'Built-in templates for Mapbox and Cloudmade have been removed. '
                'You can still use these providers by passing a URL to the `tiles` '
                'argument. See the documentation of the `TileLayer` class.')
        templates = list(
            self._env.list_templates(
                filter_func=lambda x: x.startswith('tiles/')))
        tile_template = 'tiles/' + tiles_flat + '/tiles.txt'
        attr_template = 'tiles/' + tiles_flat + '/attr.txt'

        if tile_template in templates and attr_template in templates:
            self.tiles = self._env.get_template(tile_template).render()
            attr = self._env.get_template(attr_template).render()
        else:
            self.tiles = tiles
            if not attr:
                raise ValueError('Custom tiles must have an attribution.')

        self.options = parse_options(min_zoom=min_zoom,
                                     max_zoom=max_zoom,
                                     max_native_zoom=max_native_zoom
                                     or max_zoom,
                                     no_wrap=no_wrap,
                                     attribution=attr,
                                     subdomains=subdomains,
                                     detect_retina=detect_retina,
                                     tms=tms,
                                     opacity=opacity,
                                     **kwargs)
Exemple #13
0
    def __init__(self,
                 html=None,
                 parse_html=False,
                 max_width='100%',
                 show=False,
                 sticky=False,
                 **kwargs):
        super(Popup, self).__init__()
        self._name = 'Popup'
        self.header = Element()
        self.html = Element()
        self.script = Element()

        self.header._parent = self
        self.html._parent = self
        self.script._parent = self

        script = not parse_html

        if isinstance(html, Element):
            self.html.add_child(html)
        elif isinstance(html, str):
            self.html.add_child(Html(html, script=script))

        self.show = show
        self.options = parse_options(
            max_width=max_width,
            autoClose=False if show or sticky else None,
            closeOnClick=False if sticky else None,
            **kwargs)
    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:
            locations = validate_locations(locations)
            for i, location in enumerate(locations):
                self.add_child(
                    Marker(location,
                           popup=popups and popups[i],
                           icon=icons and icons[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
Exemple #15
0
 def __init__(self,
              data,
              name=None,
              min_opacity=0.5,
              max_zoom=18,
              max_val=1.0,
              radius=25,
              blur=15,
              gradient=None,
              overlay=True,
              control=True,
              show=True,
              **kwargs):
     super(HeatMap, self).__init__(name=name,
                                   overlay=overlay,
                                   control=control,
                                   show=show)
     self._name = 'HeatMap'
     data = if_pandas_df_convert_to_numpy(data)
     self.data = [
         [*validate_location(line[:2]), *line[2:]]  # noqa: E999
         for line in data
     ]
     if np.any(np.isnan(self.data)):
         raise ValueError('data may not contain NaNs.')
     self.options = parse_options(min_opacity=min_opacity,
                                  max_zoom=max_zoom,
                                  max=max_val,
                                  radius=radius,
                                  blur=blur,
                                  gradient=gradient,
                                  **kwargs)
    def __init__(self, data, transition_time=200, loop=True, auto_play=True,
                 add_last_point=True, period='P1D', min_speed=0.1, max_speed=10,
                 loop_button=False, date_options='YYYY-MM-DD HH:mm:ss',
                 time_slider_drag_update=False, duration=None):
        super(TimestampedGeoJson, self).__init__()
        self._name = 'TimestampedGeoJson'

        if 'read' in dir(data):
            self.embed = True
            self.data = data.read()
        elif type(data) is dict:
            self.embed = True
            self.data = json.dumps(data)
        else:
            self.embed = False
            self.data = data
        self.add_last_point = bool(add_last_point)
        self.period = period
        self.date_options = date_options
        self.duration = 'undefined' if duration is None else '"' + duration + '"'

        self.options = parse_options(
            position='bottomleft',
            min_speed=min_speed,
            max_speed=max_speed,
            auto_play=auto_play,
            loop_button=loop_button,
            time_slider_drag_update=time_slider_drag_update,
            player_options={
                'transitionTime': int(transition_time),
                'loop': loop,
                'startOver': True
            },
        )
Exemple #17
0
 def __init__(self,
              data,
              name=None,
              min_opacity=0.5,
              max_zoom=18,
              max_val=1.0,
              radius=25,
              blur=15,
              gradient=None,
              overlay=True,
              control=True,
              show=True,
              **kwargs):
     super(HeatMap, self).__init__(name=name,
                                   overlay=overlay,
                                   control=control,
                                   show=show)
     data = _iter_tolist(data)
     if _isnan(data):
         raise ValueError('data cannot contain NaNs, '
                          'got:\n{!r}'.format(data))
     self._name = 'HeatMap'
     self.data = [[x for x in line] for line in data]
     self.options = parse_options(min_opacity=min_opacity,
                                  max_zoom=max_zoom,
                                  max=max_val,
                                  radius=radius,
                                  blur=blur,
                                  gradient=gradient,
                                  **kwargs)
 def __init__(self,
              url,
              layers,
              styles='',
              fmt='image/jpeg',
              transparent=False,
              version='1.1.1',
              attr='',
              name=None,
              overlay=True,
              control=True,
              show=True,
              **kwargs):
     super(WmsTileLayer, self).__init__(name=name,
                                        overlay=overlay,
                                        control=control,
                                        show=show)
     self.url = url
     kwargs['format'] = fmt
     self.options = parse_options(layers=layers,
                                  styles=styles,
                                  transparent=transparent,
                                  version=version,
                                  attribution=attr,
                                  **kwargs)
Exemple #19
0
 def __init__(self, name=None, overlay=True, control=True, show=True,
              **kwargs):
     super(FeatureGroup, self).__init__(name=name, overlay=overlay,
                                        control=control, show=show)
     self._name = 'FeatureGroup'
     self.tile_name = name if name is not None else self.get_name()
     self.options = parse_options(**kwargs)
Exemple #20
0
 def __init__(self,
              data,
              name=None,
              min_opacity=0.5,
              max_zoom=18,
              radius=25,
              blur=15,
              gradient=None,
              overlay=True,
              control=True,
              show=True,
              **kwargs):
     super(HeatMap, self).__init__(name=name,
                                   overlay=overlay,
                                   control=control,
                                   show=show)
     self._name = 'HeatMap'
     data = if_pandas_df_convert_to_numpy(data)
     self.data = [
         [*validate_location(line[:2]), *line[2:]]  # noqa: E999
         for line in data
     ]
     if np.any(np.isnan(self.data)):
         raise ValueError('data may not contain NaNs.')
     if kwargs.pop('max_val', None):
         warnings.warn(
             'The `max_val` parameter is no longer necessary. '
             'The largest intensity is calculated automatically.',
             stacklevel=2)
     self.options = parse_options(min_opacity=min_opacity,
                                  max_zoom=max_zoom,
                                  radius=radius,
                                  blur=blur,
                                  gradient=gradient,
                                  **kwargs)
Exemple #21
0
    def __init__(self,
                 tiles='OpenStreetMap',
                 min_zoom=0,
                 max_zoom=18,
                 max_native_zoom=None,
                 attr=None,
                 API_key=None,
                 detect_retina=False,
                 name=None,
                 overlay=False,
                 control=True,
                 show=True,
                 no_wrap=False,
                 subdomains='abc',
                 tms=False,
                 opacity=1,
                 **kwargs):

        self.tile_name = (name if name is not None else ''.join(
            tiles.lower().strip().split()))
        super(TileLayer, self).__init__(name=self.tile_name,
                                        overlay=overlay,
                                        control=control,
                                        show=show)
        self._name = 'TileLayer'
        self._env = ENV

        self.options = parse_options(min_zoom=min_zoom,
                                     max_zoom=max_zoom,
                                     max_native_zoom=max_native_zoom
                                     or max_zoom,
                                     no_wrap=no_wrap,
                                     attribution=attr,
                                     subdomains=subdomains,
                                     detect_retina=detect_retina,
                                     tms=tms,
                                     opacity=opacity,
                                     **kwargs)
        tiles_flat = ''.join(tiles.lower().strip().split())
        if tiles_flat in ('cloudmade', 'mapbox') and not API_key:
            raise ValueError('You must pass an API key if using Cloudmade'
                             ' or non-default Mapbox tiles.')
        templates = list(
            self._env.list_templates(
                filter_func=lambda x: x.startswith('tiles/')))
        tile_template = 'tiles/' + tiles_flat + '/tiles.txt'
        attr_template = 'tiles/' + tiles_flat + '/attr.txt'

        if tile_template in templates and attr_template in templates:
            self.tiles = self._env.get_template(tile_template).render(
                API_key=API_key)  # noqa
            self.attr = self._env.get_template(attr_template).render()
        else:
            self.tiles = tiles
            if not attr:
                raise ValueError('Custom tiles must have an attribution.')
            if isinstance(attr, binary_type):
                attr = text_type(attr, 'utf8')
            self.attr = attr
Exemple #22
0
 def __init__(self, bounds, padding_top_left=None,
              padding_bottom_right=None, padding=None, max_zoom=None):
     super(FitBounds, self).__init__()
     self._name = 'FitBounds'
     self.bounds = bounds
     self.options = parse_options(
         max_zoom=max_zoom,
         padding_top_left=padding_top_left,
         padding_bottom_right=padding_bottom_right,
         padding=padding,
     )
Exemple #23
0
 def __init__(self,
              collapsed=False,
              position='topright',
              add_marker=True,
              **kwargs):
     super(Geocoder, self).__init__()
     self._name = 'Geocoder'
     self.options = parse_options(collapsed=collapsed,
                                  position=position,
                                  defaultMarkGeocode=add_marker,
                                  **kwargs)
Exemple #24
0
 def __init__(self, bounds, padding_top_left=None,
              padding_bottom_right=None, padding=None, max_zoom=None):
     super(FitBounds, self).__init__()
     self._name = 'FitBounds'
     self.bounds = bounds
     self.options = parse_options(
         max_zoom=max_zoom,
         padding_top_left=padding_top_left,
         padding_bottom_right=padding_bottom_right,
         padding=padding,
     )
Exemple #25
0
 def __init__(self, location, popup=None, icon=None,
              heading=0, wind_heading=None, wind_speed=0, **kwargs):
     super(BoatMarker, self).__init__(
         location,
         popup=popup,
         icon=icon
     )
     self._name = 'BoatMarker'
     self.heading = heading
     self.wind_heading = wind_heading
     self.wind_speed = wind_speed
     self.options = parse_options(**kwargs)
Exemple #26
0
 def __init__(self, position='topleft', title='Full Screen',
              title_cancel='Exit Full Screen', force_separate_button=False,
              **kwargs):
     super(Fullscreen, self).__init__()
     self._name = 'Fullscreen'
     self.options = parse_options(
         position=position,
         title=title,
         title_cancel=title_cancel,
         force_separate_button=force_separate_button,
         **kwargs
     )
Exemple #27
0
 def __init__(self, width=20, height=20, radius=12, weight=2.0,
              color="#3388ff", fill_color="#3388ff",
              opacity=0.75, fill_opacity=0.5):
     super(CirclePattern, self).__init__()
     self._name = 'CirclePattern'
     self.options_pattern_circle = parse_options(
         x=radius + 2 * weight,
         y=radius + 2 * weight,
         weight=weight,
         radius=radius,
         color=color,
         fill_color=fill_color,
         opacity=opacity,
         fill_opacity=fill_opacity,
         fill=True,
     )
     self.options_pattern = parse_options(
         width=width,
         height=height,
     )
     self.parent_map = None
 def __init__(self, location, popup=None, icon=None,
              heading=0, wind_heading=None, wind_speed=0, **kwargs):
     super(BoatMarker, self).__init__(
         location,
         popup=popup,
         icon=icon
     )
     self._name = 'BoatMarker'
     self.heading = heading
     self.wind_heading = wind_heading
     self.wind_speed = wind_speed
     self.options = parse_options(**kwargs)
Exemple #29
0
 def __init__(self, position='topright', collapsed=True, autoZIndex=True,
              **kwargs):
     super(LayerControl, self).__init__()
     self._name = 'LayerControl'
     self.options = parse_options(
         position=position,
         collapsed=collapsed,
         autoZIndex=autoZIndex,
         **kwargs
     )
     self.base_layers = OrderedDict()
     self.overlays = OrderedDict()
     self.layers_untoggle = OrderedDict()
Exemple #30
0
    def __init__(self, video_url, bounds, autoplay=True, loop=True,
                 name=None, overlay=True, control=True, show=True, **kwargs):
        super(VideoOverlay, self).__init__(name=name, overlay=overlay,
                                           control=control, show=show)
        self._name = 'VideoOverlay'
        self.video_url = video_url

        self.bounds = bounds
        self.options = parse_options(
            autoplay=autoplay,
            loop=loop,
            **kwargs
        )
Exemple #31
0
 def __init__(self, position='topright', collapsed=True, autoZIndex=True,
              **kwargs):
     super(LayerControl, self).__init__()
     self._name = 'LayerControl'
     self.options = parse_options(
         position=position,
         collapsed=collapsed,
         autoZIndex=autoZIndex,
         **kwargs
     )
     self.base_layers = OrderedDict()
     self.overlays = OrderedDict()
     self.layers_untoggle = OrderedDict()
 def __init__(self,
              data,
              yawn=60,
              size="15%",
              frequency="allvertices",
              proportionalToTotal=False,
              **kwargs):
     super(GeoJsonWithArrows, self).__init__(data, **kwargs)
     self._name = 'GeoJsonWithArrows'
     self.arrows_options = parse_options(
         yawn=yawn,
         size=size,
         frequency=frequency,
         proportionalToTotal=proportionalToTotal)
Exemple #33
0
    def __init__(self, position='topright', primary_length_unit='meters',
                 secondary_length_unit='miles', primary_area_unit='sqmeters',
                 secondary_area_unit='acres', **kwargs):

        super(MeasureControl, self).__init__()
        self._name = 'MeasureControl'

        self.options = parse_options(
            position=position,
            primary_length_unit=primary_length_unit,
            secondary_length_unit=secondary_length_unit,
            primary_area_unit=primary_area_unit,
            secondary_area_unit=secondary_area_unit,
            **kwargs
        )
Exemple #34
0
 def __init__(self, color='blue', icon_color='white', icon='info-sign',
              angle=0, prefix='glyphicon', **kwargs):
     super(Icon, self).__init__()
     self._name = 'Icon'
     if color not in self.color_options:
         warnings.warn('color argument of Icon should be one of: {}.'
                       .format(self.color_options), stacklevel=2)
     self.options = parse_options(
         color=color,
         icon_color=icon_color,
         icon=icon,
         prefix=prefix,
         extra_classes='fa-rotate-{}'.format(angle),
         **kwargs
     )
Exemple #35
0
 def __init__(self, polyline, text, repeat=False, center=False, below=False,
              offset=0, orientation=0, attributes=None, **kwargs):
     super(PolyLineTextPath, self).__init__()
     self._name = 'PolyLineTextPath'
     self.polyline = polyline
     self.text = text
     self.options = parse_options(
         repeat=repeat,
         center=center,
         below=below,
         offset=offset,
         orientation=orientation,
         attributes=attributes,
         **kwargs
     )
 def __init__(self, data, transition_time=200, loop=False, auto_play=False,
              period='P1D', time_interval=False, name=None,
              overlay=True, control=True, show=True):
     super(TimestampedWmsTileLayers, self).__init__(name=name,
                                                    overlay=overlay,
                                                    control=control,
                                                    show=show)
     self._name = 'TimestampedWmsTileLayers'
     self.options = parse_options(
         period=period,
         time_interval=time_interval,
     )
     self.options_control = parse_options(
         position='bottomleft',
         auto_play=auto_play,
         player_options={
             'transitionTime': int(transition_time),
             'loop': loop,
         },
     )
     if isinstance(data, WmsTileLayer):
         self.layers = [data]
     else:
         self.layers = data  # Assume iterable
Exemple #37
0
 def __init__(self, color='blue', icon_color='white', icon='info-sign',
              angle=0, prefix='glyphicon', **kwargs):
     super(Icon, self).__init__()
     self._name = 'Icon'
     if color not in self.color_options:
         warnings.warn('color argument of Icon should be one of: {}.'
                       .format(self.color_options), stacklevel=2)
     self.options = parse_options(
         marker_color=color,
         icon_color=icon_color,
         icon=icon,
         prefix=prefix,
         extra_classes='fa-rotate-{}'.format(angle),
         **kwargs
     )
Exemple #38
0
 def __init__(self, polyline, text, repeat=False, center=False, below=False,
              offset=0, orientation=0, attributes=None, **kwargs):
     super(PolyLineTextPath, self).__init__()
     self._name = 'PolyLineTextPath'
     self.polyline = polyline
     self.text = text
     self.options = parse_options(
         repeat=repeat,
         center=center,
         below=below,
         offset=offset,
         orientation=orientation,
         attributes=attributes,
         **kwargs
     )
Exemple #39
0
 def __init__(self, url, layers, styles='', fmt='image/jpeg',
              transparent=False, version='1.1.1', attr='',
              name=None, overlay=True, control=True, show=True, **kwargs):
     super(WmsTileLayer, self).__init__(name=name, overlay=overlay,
                                        control=control, show=show)
     self.url = url
     kwargs['format'] = fmt
     self.options = parse_options(
         layers=layers,
         styles=styles,
         transparent=transparent,
         version=version,
         attribution=attr,
         **kwargs
     )
Exemple #40
0
    def __init__(self, position='topright', primary_length_unit='meters',
                 secondary_length_unit='miles', primary_area_unit='sqmeters',
                 secondary_area_unit='acres', **kwargs):

        super(MeasureControl, self).__init__()
        self._name = 'MeasureControl'

        self.options = parse_options(
            position=position,
            primary_length_unit=primary_length_unit,
            secondary_length_unit=secondary_length_unit,
            primary_area_unit=primary_area_unit,
            secondary_area_unit=secondary_area_unit,
            **kwargs
        )
Exemple #41
0
 def __init__(self, angle=.5, weight=4, space_weight=4,
              color="#000000", space_color="#ffffff",
              opacity=0.75, space_opacity=0.0, **kwargs):
     super(StripePattern, self).__init__()
     self._name = 'StripePattern'
     self.options = parse_options(
         angle=angle,
         weight=weight,
         space_weight=space_weight,
         color=color,
         space_color=space_color,
         opacity=opacity,
         space_opacity=space_opacity,
         **kwargs
     )
     self.parent_map = None
Exemple #42
0
 def __init__(self, angle=.5, weight=4, space_weight=4,
              color="#000000", space_color="#ffffff",
              opacity=0.75, space_opacity=0.0, **kwargs):
     super(StripePattern, self).__init__()
     self._name = 'StripePattern'
     self.options = parse_options(
         angle=angle,
         weight=weight,
         space_weight=space_weight,
         color=color,
         space_color=space_color,
         opacity=opacity,
         space_opacity=space_opacity,
         **kwargs
     )
     self.parent_map = None
Exemple #43
0
 def __init__(self, layer, search_label=None, search_zoom=None,
              geom_type='Point', position='topleft', placeholder='Search',
              collapsed=False, **kwargs):
     super(Search, self).__init__()
     assert isinstance(layer,
                       (GeoJson, MarkerCluster, FeatureGroup, TopoJson)
                       ), 'Search can only index FeatureGroup, ' \
                          'MarkerCluster, GeoJson, and TopoJson layers at ' \
                          'this time.'
     self.layer = layer
     self.search_label = search_label
     self.search_zoom = search_zoom
     self.geom_type = geom_type
     self.position = position
     self.placeholder = placeholder
     self.collapsed = collapsed
     self.options = parse_options(**kwargs)
Exemple #44
0
 def __init__(self, layer, search_label=None, search_zoom=None,
              geom_type='Point', position='topleft', placeholder='Search',
              collapsed=False, **kwargs):
     super(Search, self).__init__()
     assert isinstance(layer,
                       (GeoJson, MarkerCluster, FeatureGroup, TopoJson)
                       ), 'Search can only index FeatureGroup, ' \
                          'MarkerCluster, GeoJson, and TopoJson layers at ' \
                          'this time.'
     self.layer = layer
     self.search_label = search_label
     self.search_zoom = search_zoom
     self.geom_type = geom_type
     self.position = position
     self.placeholder = placeholder
     self.collapsed = collapsed
     self.options = parse_options(**kwargs)
Exemple #45
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)
Exemple #46
0
    def __init__(self, position='bottomright', separator=' : ',
                 empty_string='Unavailable', lng_first=False, num_digits=5,
                 prefix='', lat_formatter=None, lng_formatter=None, **kwargs):

        super(MousePosition, self).__init__()
        self._name = 'MousePosition'

        self.options = parse_options(
            position=position,
            separator=separator,
            empty_string=empty_string,
            lng_first=lng_first,
            num_digits=num_digits,
            prefix=prefix,
            **kwargs
        )
        self.lat_formatter = lat_formatter or 'undefined'
        self.lng_formatter = lng_formatter or 'undefined'
Exemple #47
0
 def __init__(self, location, popup=None, tooltip=None, icon=None,
              draggable=False, **kwargs):
     super(Marker, self).__init__()
     self._name = 'Marker'
     self.location = validate_location(location)
     self.options = parse_options(
         draggable=draggable or None,
         autoPan=draggable or None,
         **kwargs
     )
     if icon is not None:
         self.add_child(icon)
     if popup is not None:
         self.add_child(popup if isinstance(popup, Popup)
                        else Popup(str(popup)))
     if tooltip is not None:
         self.add_child(tooltip if isinstance(tooltip, Tooltip)
                        else Tooltip(str(tooltip)))
    def __init__(self, position='bottomright', separator=' : ',
                 empty_string='Unavailable', lng_first=False, num_digits=5,
                 prefix='', lat_formatter=None, lng_formatter=None, **kwargs):

        super(MousePosition, self).__init__()
        self._name = 'MousePosition'

        self.options = parse_options(
            position=position,
            separator=separator,
            empty_string=empty_string,
            lng_first=lng_first,
            num_digits=num_digits,
            prefix=prefix,
            **kwargs
        )
        self.lat_formatter = lat_formatter or 'undefined'
        self.lng_formatter = lng_formatter or 'undefined'
Exemple #49
0
    def __init__(self, tiles='OpenStreetMap', min_zoom=0, max_zoom=18,
                 max_native_zoom=None, attr=None, API_key=None,
                 detect_retina=False, name=None, overlay=False,
                 control=True, show=True, no_wrap=False, subdomains='abc',
                 tms=False, opacity=1, **kwargs):

        self.tile_name = (name if name is not None else
                          ''.join(tiles.lower().strip().split()))
        super(TileLayer, self).__init__(name=self.tile_name, overlay=overlay,
                                        control=control, show=show)
        self._name = 'TileLayer'
        self._env = ENV

        tiles_flat = ''.join(tiles.lower().strip().split())
        if tiles_flat in ('cloudmade', 'mapbox') and not API_key:
            raise ValueError('You must pass an API key if using Cloudmade'
                             ' or non-default Mapbox tiles.')
        templates = list(self._env.list_templates(
            filter_func=lambda x: x.startswith('tiles/')))
        tile_template = 'tiles/' + tiles_flat + '/tiles.txt'
        attr_template = 'tiles/' + tiles_flat + '/attr.txt'

        if tile_template in templates and attr_template in templates:
            self.tiles = self._env.get_template(tile_template).render(API_key=API_key)  # noqa
            attr = self._env.get_template(attr_template).render()
        else:
            self.tiles = tiles
            if not attr:
                raise ValueError('Custom tiles must have an attribution.')

        self.options = parse_options(
            min_zoom=min_zoom,
            max_zoom=max_zoom,
            max_native_zoom=max_native_zoom or max_zoom,
            no_wrap=no_wrap,
            attribution=attr,
            subdomains=subdomains,
            detect_retina=detect_retina,
            tms=tms,
            opacity=opacity,
            **kwargs
        )
Exemple #50
0
    def __init__(self, icon=None, icon_shape=None, border_width=3,
                 border_color='#000', text_color='#000',
                 background_color='#FFF', inner_icon_style='', spin=False,
                 number=None, **kwargs):
        super(BeautifyIcon, self).__init__()
        self._name = 'BeautifyIcon'

        self.options = parse_options(
            icon=icon,
            icon_shape=icon_shape,
            border_width=border_width,
            border_color=border_color,
            text_color=text_color,
            background_color=background_color,
            inner_icon_style=inner_icon_style,
            spin=spin,
            isAlphaNumericIcon=number is not None,
            text=number,
            **kwargs
        )
Exemple #51
0
 def __init__(self, data, name=None, min_opacity=0.5, max_zoom=18,
              max_val=1.0, radius=25, blur=15, gradient=None,
              overlay=True, control=True, show=True, **kwargs):
     super(HeatMap, self).__init__(name=name, overlay=overlay,
                                   control=control, show=show)
     self._name = 'HeatMap'
     data = if_pandas_df_convert_to_numpy(data)
     self.data = [[*validate_location(line[:2]), *line[2:]]  # noqa: E999
                  for line in data]
     if np.any(np.isnan(self.data)):
         raise ValueError('data may not contain NaNs.')
     self.options = parse_options(
         min_opacity=min_opacity,
         max_zoom=max_zoom,
         max=max_val,
         radius=radius,
         blur=blur,
         gradient=gradient,
         **kwargs
     )
Exemple #52
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:
            locations = validate_locations(locations)
            for i, location in enumerate(locations):
                self.add_child(Marker(location,
                                      popup=popups and popups[i],
                                      icon=icons and icons[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
Exemple #53
0
    def __init__(
            self,
            location=None,
            width='100%',
            height='100%',
            left='0%',
            top='0%',
            position='relative',
            tiles='OpenStreetMap',
            attr=None,
            min_zoom=0,
            max_zoom=18,
            zoom_start=10,
            min_lat=-90,
            max_lat=90,
            min_lon=-180,
            max_lon=180,
            max_bounds=False,
            crs='EPSG3857',
            control_scale=False,
            prefer_canvas=False,
            no_touch=False,
            disable_3d=False,
            png_enabled=False,
            zoom_control=True,
            **kwargs
    ):
        super(Map, self).__init__()
        self._name = 'Map'
        self._env = ENV
        # Undocumented for now b/c this will be subject to a re-factor soon.
        self._png_image = None
        self.png_enabled = png_enabled

        if location is None:
            # If location is not passed we center and zoom out.
            self.location = [0, 0]
            zoom_start = 1
        else:
            self.location = validate_location(location)

        Figure().add_child(self)

        # Map Size Parameters.
        self.width = _parse_size(width)
        self.height = _parse_size(height)
        self.left = _parse_size(left)
        self.top = _parse_size(top)
        self.position = position

        max_bounds_array = [[min_lat, min_lon], [max_lat, max_lon]] \
            if max_bounds else None

        self.crs = crs
        self.control_scale = control_scale

        self.options = parse_options(
            max_bounds=max_bounds_array,
            zoom=zoom_start,
            zoom_control=zoom_control,
            prefer_canvas=prefer_canvas,
            **kwargs
        )

        self.global_switches = GlobalSwitches(
            no_touch,
            disable_3d
        )

        self.objects_to_stay_in_front = []

        if tiles:
            tile_layer = TileLayer(tiles=tiles, attr=attr,
                                   min_zoom=min_zoom, max_zoom=max_zoom)
            self.add_child(tile_layer, name=tile_layer.tile_name)
Exemple #54
0
 def __init__(self, **kwargs):
     super(LocateControl, self).__init__()
     self._name = 'LocateControl'
     self.options = parse_options(**kwargs)
Exemple #55
0
def test_parse_options():
    assert parse_options(thing=42) == {'thing': 42}
    assert parse_options(thing=None) == {}
    assert parse_options(long_thing=42) == {'longThing': 42}
    assert parse_options(thing=42, lst=[1, 2]) == {'thing': 42, 'lst': [1, 2]}