1313 text_type , binary_type )
1414
1515from .element import Element , Figure , JavascriptLink , CssLink , MacroElement
16- from .map import TileLayer , Icon , Marker , Popup
16+ from .map import Layer , Icon , Marker , Popup
1717
18-
19- class WmsTileLayer (TileLayer ):
18+ class WmsTileLayer (Layer ):
2019 def __init__ (self , url , name = None ,
2120 format = None , layers = None , transparent = True ,
22- attr = None , overlay = True ):
21+ attr = None , overlay = True , control = True ):
2322 """
2423 TODO docstring here
2524
2625 """
27- super (TileLayer , self ).__init__ ()
26+ super (WmsTileLayer , self ).__init__ (overlay = overlay , control = control )
2827 self ._name = 'WmsTileLayer'
2928 self .tile_name = name if name is not None else 'WmsTileLayer_' + self ._id
3029 self .url = url
3130 self .format = format
3231 self .layers = layers
33- self .overlay = overlay
3432 self .transparent = transparent
3533 self .attr = attr
3634
@@ -49,7 +47,6 @@ def __init__(self, url, name=None,
4947 {% endmacro %}
5048 """ ) # noqa
5149
52-
5350class RegularPolygonMarker (Marker ):
5451 def __init__ (self , location , color = 'black' , opacity = 1 , weight = 2 ,
5552 fill_color = 'blue' , fill_opacity = 1 ,
@@ -338,16 +335,16 @@ def render(self, **kwargs):
338335 name = 'd3' )
339336
340337
341- class MarkerCluster (MacroElement ):
338+ class MarkerCluster (Layer ):
342339 """Adds a MarkerCluster layer on the map."""
343- def __init__ (self ):
340+ def __init__ (self , overlay = True , control = True ):
344341 """Creates a MarkerCluster element to append into a map with
345342 Map.add_children.
346343
347344 Parameters
348345 ----------
349346 """
350- super (MarkerCluster , self ).__init__ ()
347+ super (MarkerCluster , self ).__init__ (overlay = overlay , control = control )
351348 self ._name = 'MarkerCluster'
352349 self ._template = Template (u"""
353350 {% macro script(this, kwargs) %}
@@ -610,69 +607,6 @@ def __init__(self, locations, color=None, weight=None,
610607 {% endmacro %}
611608 """ ) # noqa
612609
613-
614- class ImageOverlay (MacroElement ):
615- def __init__ (self , image , bounds , opacity = 1. , attr = None ,
616- origin = 'upper' , colormap = None , mercator_project = False ):
617- """
618- Used to load and display a single image over specific bounds of
619- the map, implements ILayer interface.
620-
621- Parameters
622- ----------
623- image: string, file or array-like object
624- The data you want to draw on the map.
625- * If string, it will be written directly in the output file.
626- * If file, it's content will be converted as embedded in the
627- output file.
628- * If array-like, it will be converted to PNG base64 string
629- and embedded in the output.
630- bounds: list
631- Image bounds on the map in the form [[lat_min, lon_min],
632- [lat_max, lon_max]]
633- opacity: float, default Leaflet's default (1.0)
634- attr: string, default Leaflet's default ("")
635- origin : ['upper' | 'lower'], optional, default 'upper'
636- Place the [0,0] index of the array in the upper left or
637- lower left corner of the axes.
638- colormap : callable, used only for `mono` image.
639- Function of the form [x -> (r,g,b)] or [x -> (r,g,b,a)]
640- for transforming a mono image into RGB.
641- It must output iterables of length 3 or 4,
642- with values between 0 and 1.
643- Hint : you can use colormaps from `matplotlib.cm`.
644- mercator_project : bool, default False.
645- Used only for array-like image. Transforms the data to
646- project (longitude, latitude) coordinates to the
647- Mercator projection.
648-
649- """
650- super (ImageOverlay , self ).__init__ ()
651- self ._name = 'ImageOverlay'
652-
653- self .url = image_to_url (image , origin = origin ,
654- mercator_project = mercator_project ,
655- bounds = bounds )
656-
657- self .bounds = json .loads (json .dumps (bounds ))
658- options = {
659- 'opacity' : opacity ,
660- 'attribution' : attr ,
661- }
662- self .options = json .dumps ({key : val for key , val
663- in options .items () if val },
664- sort_keys = True )
665- self ._template = Template (u"""
666- {% macro script(this, kwargs) %}
667- var {{this.get_name()}} = L.imageOverlay(
668- '{{ this.url }}',
669- {{ this.bounds }},
670- {{ this.options }}
671- ).addTo({{this._parent.get_name()}});
672- {% endmacro %}
673- """ )
674-
675-
676610class CustomIcon (Icon ):
677611 def __init__ (self , icon_image , icon_size = None , icon_anchor = None ,
678612 shadow_image = None , shadow_size = None , shadow_anchor = None ,
0 commit comments