
    h;                         d dl Z d dlmZ d dlZd dlZd dlmZ d dl	m
Z
 d dlZg dZddddddddddddd	ddd
d
ddddi i i i i i i i fdZd Zd Zdddddd
d
ddi i i i fdZy)    N)mean)is_datetime64_any_dtype
LineString)locationprefer_canvasno_touch
disable_3dpng_enabledzoom_controlcrs
zoom_startlefttoppositionmin_zoommax_zoommin_latmax_latmin_lonmax_lon
max_boundsOpenStreetMapTF   z100%c                 *  STU d[Sfd	}	 ddl } ddl}!ddl}"ddlm}# ddlm}$ ddlmS ddlm	}% 	 ddl}&d}'| j                         }(| j                  d
k(  })|)j                         r,|(j                   |)   j#                  d       |(j                   |)<   t%        |(t&        j(                        r|(j+                         }(|(j,                  d|d<   d}n,|(j,                  j/                  d      s|(j1                  d      }(|(j2                  |(j2                  D *cg c]  }*t5        |(|*          c}*   j7                  |(j2                  |(j8                  dk(           }+t;        |+      dkD  r |(j=                  |+D *ci c]  }*|*d c}*      }(t%        |(j>                  t@        jB                        sNt5        |(j>                        s|(j>                  jD                  dk(  r |(j>                  j=                  d      |(_        ||(jF                  },|jI                  dd      }-|-etK        jL                  |,      jO                         sBtQ        |,d   |,d   g      }.tQ        |,d   |,d   g      }/|/|.f}-d|jS                         v rd	}0nd}0nd	}0tT        D ]  }1|1|v stW        d|1 d|1 d||1    d       i ||jS                         D 1ci c]  }1|1tT        v s|1||1    c}1}|'rt%        |tX              r	 &jZ                  j]                  |      }t%        |&j^                        rT|r|n|j`                  }d|vr|jc                  dd      |d<   d|vr|jc                  dd      |d<   |je                  d      } |"jf                  d\|-|||||d|}|0r#|ji                  |,d   |,d   g|,d   |,d   gg       |(jj                  jO                         rtm        jn                  d tp        d!       |S tT        D ]  }2|jI                  |2d        d}3|0t@        jr                  jt                  jw                  |      r0t;        |      |(jx                  d   k7  rtW        d"      d#}4||(|4<   |4}nt%        |(|   jD                  t@        jz                        r|tW        d$      d}
nt@        jr                  jt                  j}                  |(|         sZt@        jr                  jt                  j                  |(|         s.t@        jr                  jt                  j                  |(|         s|rd}
tA        j                  |(|         }3|
rtA        j                  |(|   |3    |%      }5t;        |5j                        }6|r|nd&}||#j                         v ritK        j                  |%j                  d |||6|5j                  '            tK        j                  |%j                  d |||6t        |6      '            }7nIt%        ||%j                        rctK        j                  |%j                  d ||5j                              tK        j                  |%j                  d |t        |6                  }7nt@        jr                  jt                  jw                  |      rc|6t;        |      kD  r||6t;        |      z  dz   z  }tK        j                  ||5j                        tK        j                  |t        |6            }7nDtW        d(      t        |      r| |   D .cg c]
  }. ||.       c}.n||(|   j                         n|}||(|   j                         n|}|p|i }d)|vr||d)<    |$tK        j                  |(|   |3          |fi |}8tK        j                  |%j                  d |||8j                  |8j                  '            nstK        j                  ||d*      dd }9 |$tK        j                  |(|   |3          d+|9,      }8tK        j                  |%j                  d ||d-|8j                  '            d.vrd/d.<   d0vrdd0<   d1v r-d1   Ut        U      stW        d2      jI                  d1       nd3 }:|:Ut%        tX              r2t%        |(t&        j                        r|(j2                  v r
Ufd4};|;}<nt%        |(t&        j(                        rt'        j                  |(5      }(|3:|3j                         r*|jI                  d6d      }=|=|(d7<   |(j                  |3 d7f<   n|(d7<   jI                  d6d      TTs	Ufd8}>|>}<nTUfd9}?|?}<nUfd:}@|@}<|	rd.vrd;d.<   fd<}A|A}Bnd}B|d=}|}Ct%        |tX              r}|d>k(  r |"j                  d\i |}Cne|d?k(  r |"j                  d\i |}CnM|d=k(  r=|jc                  d@d      |d@<   |jc                  dAd      |dA<    |"j                  d\i |}CntW        dB      t%        |(t&        j                        r\|(j8                  dCk(  j                         D DEcg c]"  \  }D}E|ErD|(j                   j                  k7  rD$ }F}D}E|(j                  |FD      }(t%        |(t&        j                        rC|(j>                  j                  |(j                         }(t        dE||(fi |}t        dF||(fi |}nd}d}|(|(j                   j                         |(j                   jj                  z      j                  }G|GdG   D ]C  }H|HdH   D ]9  }It%        HdH   |I   tX              s| j                  dIdJ HdH   I         |HdH   |I<   ; E  |"j                  Gf||C|<BdK|j                  |       |r|d#k(  s|ndL}J|jI                  dM|J      }J|
r~5j                  j                         }7j                         }7|3j                         r4=r2|j                  |jI                  dNdO             |7j                  |=       t        |J||7       |S |v|jI                  dPd      }Ki }LdQ|v r|jI                  dQ      LdQ<   |rKtK        j                  |%j                  d ||8j                  t        |8j                        '            }MKrW|jI                  dRd      r|g|8j                  j                         z   }Nnd}N |!j                  j                  Mf||JNdSL}Onb|jI                  dTdU      }PdV|v r|dV   }n7|8j                  P      }|jI                  dWd	      }Q|Qs|D *cg c]  }*|*ddX 	 }}*|3j                         r9=r7|j                  |jI                  dNdO             tK        j                  M|=      }Mt        |J|M       nt%        ||!j                  j                        r|}On ||      }RtK        j                  |%j                  d |Rt        |Rj                                    }M|Rj                  dYkD  r" |!j                  j                  Mf||JdZL}On! |!j                  j                  Mf||JdZL}OKrC|3j                         r"=r t        |dL|jI                  dNdO      g|=g       |j                  O       |S # t        t        f$ r t        d      w xY w# t        t        f$ r d	}'Y w xY wc c}*w c c}*w c c}1w # tV        $ r Y w xY wc c}.w c c}E}Dw c c}*w )]uh'  Explore data in interactive map based on GeoPandas and folium/leaflet.js.

    Generate an interactive leaflet map based on :class:`~geopandas.GeoDataFrame`

    Parameters
    ----------
    column : str, np.array, pd.Series (default None)
        The name of the dataframe column, :class:`numpy.array`,
        or :class:`pandas.Series` to be plotted. If :class:`numpy.array` or
        :class:`pandas.Series` are used then it must have same length as dataframe.
    cmap : str, matplotlib.Colormap, branca.colormap or function (default None)
        The name of a colormap recognized by ``matplotlib``, a list-like of colors,
        :class:`matplotlib.colors.Colormap`, a :class:`branca.colormap.ColorMap` or
        function that returns a named color or hex based on the column
        value, e.g.::

            def my_colormap(value):  # scalar value defined in 'column'
                if value > 1:
                    return "green"
                return "red"

    color : str, array-like (default None)
        Named color or a list-like of colors (named or hex).
    m : folium.Map (default None)
        Existing map instance on which to draw the plot.
    tiles : str, xyzservices.TileProvider (default 'OpenStreetMap Mapnik')
        Map tileset to use. Can choose from the list supported by folium, query a
        :class:`xyzservices.TileProvider` by a name from ``xyzservices.providers``,
        pass :class:`xyzservices.TileProvider` object or pass custom XYZ URL.
        The current list of built-in providers (when ``xyzservices`` is not available):

        ``["OpenStreetMap", "CartoDB positron", “CartoDB dark_matter"]``

        You can pass a custom tileset to Folium by passing a Leaflet-style URL
        to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``.
        Be sure to check their terms and conditions and to provide attribution with
        the ``attr`` keyword.
    attr : str (default None)
        Map tile attribution; only required if passing custom tile URL.
    tooltip : bool, str, int, list (default True)
        Display GeoDataFrame attributes when hovering over the object.
        ``True`` includes all columns. ``False`` removes tooltip. Pass string or list of
        strings to specify a column(s). Integer specifies first n columns to be
        included. Defaults to ``True``.
    popup : bool, str, int, list (default False)
        Input GeoDataFrame attributes for object displayed when clicking.
        ``True`` includes all columns. ``False`` removes popup. Pass string or list of
        strings to specify a column(s). Integer specifies first n columns to be
        included. Defaults to ``False``.
    highlight : bool (default True)
        Enable highlight functionality when hovering over a geometry.
    categorical : bool (default False)
        If ``False``, ``cmap`` will reflect numerical values of the
        column being plotted. For non-numerical columns, this
        will be set to True.
    legend : bool (default True)
        Plot a legend in choropleth plots.
        Ignored if no ``column`` is given.
    scheme : str (default None)
        Name of a choropleth classification scheme (requires ``mapclassify`` >= 2.4.0).
        A :func:`mapclassify.classify` will be used
        under the hood. Supported are all schemes provided by ``mapclassify`` (e.g.
        ``'BoxPlot'``, ``'EqualInterval'``, ``'FisherJenks'``, ``'FisherJenksSampled'``,
        ``'HeadTailBreaks'``, ``'JenksCaspall'``, ``'JenksCaspallForced'``,
        ``'JenksCaspallSampled'``, ``'MaxP'``, ``'MaximumBreaks'``,
        ``'NaturalBreaks'``, ``'Quantiles'``, ``'Percentiles'``, ``'StdMean'``,
        ``'UserDefined'``). Arguments can be passed in ``classification_kwds``.
    k : int (default 5)
        Number of classes
    vmin : None or float (default None)
        Minimum value of ``cmap``. If ``None``, the minimum data value
        in the column to be plotted is used.
    vmax : None or float (default None)
        Maximum value of ``cmap``. If ``None``, the maximum data value
        in the column to be plotted is used.
    width : pixel int or percentage string (default: '100%')
        Width of the folium :class:`~folium.folium.Map`. If the argument
        m is given explicitly, width is ignored.
    height : pixel int or percentage string (default: '100%')
        Height of the folium :class:`~folium.folium.Map`. If the argument
        m is given explicitly, height is ignored.
    categories : list-like
        Ordered list-like object of categories to be used for categorical plot.
    classification_kwds : dict (default None)
        Keyword arguments to pass to mapclassify
    control_scale : bool, (default True)
        Whether to add a control scale on the map.
    marker_type : str, folium.Circle, folium.CircleMarker, folium.Marker (default None)
        Allowed string options are ('marker', 'circle', 'circle_marker'). Defaults to
        folium.CircleMarker.
    marker_kwds: dict (default {})
        Additional keywords to be passed to the selected ``marker_type``, e.g.:

        radius : float (default 2 for ``circle_marker`` and 50 for ``circle``))
            Radius of the circle, in meters (for ``circle``) or pixels
            (for ``circle_marker``).
        fill : bool (default True)
            Whether to fill the ``circle`` or ``circle_marker`` with color.
        icon : folium.map.Icon
            the :class:`folium.map.Icon` object to use to render the marker.
        draggable : bool (default False)
            Set to True to be able to drag the marker around the map.

    style_kwds : dict (default {})
        Additional style to be passed to folium ``style_function``:

        stroke : bool (default True)
            Whether to draw stroke along the path. Set it to ``False`` to
            disable borders on polygons or circles.
        color : str
            Stroke color
        weight : int
            Stroke width in pixels
        opacity : float (default 1.0)
            Stroke opacity
        fill : boolean (default True)
            Whether to fill the path with color. Set it to ``False`` to
            disable filling on polygons or circles.
        fillColor : str
            Fill color. Defaults to the value of the color option
        fillOpacity : float (default 0.5)
            Fill opacity.
        style_function : callable
            Function mapping a GeoJson Feature to a style ``dict``.

            * Style properties :func:`folium.vector_layers.path_options`
            * GeoJson features :class:`GeoDataFrame.__geo_interface__`

            e.g.::

                lambda x: {"color":"red" if x["properties"]["gdp_md_est"]<10**6
                                             else "blue"}

        Plus all supported by :func:`folium.vector_layers.path_options`. See the
        documentation of :class:`folium.features.GeoJson` for details.

    highlight_kwds : dict (default {})
        Style to be passed to folium highlight_function. Uses the same keywords
        as ``style_kwds``. When empty, defaults to ``{"fillOpacity": 0.75}``.
    missing_kwds : dict (default {})
        Additional style for missing values:

        color : str
            Color of missing values. Defaults to ``None``, which uses Folium's default.
        label : str (default "NaN")
            Legend entry for missing values.
    tooltip_kwds : dict (default {})
        Additional keywords to be passed to :class:`folium.features.GeoJsonTooltip`,
        e.g. ``aliases``, ``labels``, or ``sticky``.
    popup_kwds : dict (default {})
        Additional keywords to be passed to :class:`folium.features.GeoJsonPopup`,
        e.g. ``aliases`` or ``labels``.
    legend_kwds : dict (default {})
        Additional keywords to be passed to the legend.

        Currently supported customisation:

        caption : string
            Custom caption of the legend. Defaults to the column name.

        Additional accepted keywords when ``scheme`` is specified:

        colorbar : bool (default True)
            An option to control the style of the legend. If True, continuous
            colorbar will be used. If False, categorical legend will be used for bins.
        scale : bool (default True)
            Scale bins along the colorbar axis according to the bin edges (True)
            or use the equal length for each bin (False)
        fmt : string (default "{:.2f}")
            A formatting specification for the bin edges of the classes in the
            legend. For example, to have no decimals: ``{"fmt": "{:.0f}"}``. Applies
            if ``colorbar=False``.
        labels : list-like
            A list of legend labels to override the auto-generated labels.
            Needs to have the same number of elements as the number of
            classes (`k`). Applies if ``colorbar=False``.
        interval : boolean (default False)
            An option to control brackets from mapclassify legend.
            If True, open/closed interval brackets are shown in the legend.
            Applies if ``colorbar=False``.
        max_labels : int, default 10
            Maximum number of colorbar tick labels (requires branca>=0.5.0)
    map_kwds : dict (default {})
        Additional keywords to be passed to folium :class:`~folium.folium.Map`,
        e.g. ``dragging``, or ``scrollWheelZoom``.


    **kwargs : dict
        Additional options to be passed on to the folium object.

    Returns
    -------
    m : folium.folium.Map
        folium :class:`~folium.folium.Map` instance

    Examples
    --------
    >>> import geodatasets
    >>> df = geopandas.read_file(
    ...     geodatasets.get_path("geoda.chicago_health")
    ... )
    >>> df.head(2)  # doctest: +SKIP
       ComAreaID  ...                                           geometry
    0         35  ...  POLYGON ((-87.60914 41.84469, -87.60915 41.844...
    1         36  ...  POLYGON ((-87.59215 41.81693, -87.59231 41.816...

    [2 rows x 87 columns]

    >>> df.explore("Pop2012", cmap="Blues")  # doctest: +SKIP
    Nc                 v    |sj                  |       S  j                  |       j                  |      |      S )z`Return the color map specified.

        Helper function for MPL deprecation - GH#2596.
        )get_cmap	resampled)_cmap
n_resampleidxcms      D/var/www/html/immo/lib/python3.12/site-packages/geopandas/explore.py_colormap_helperz"_explore.<locals>._colormap_helper  s8    
 ;;u%%;2;;u%//
;C@@    r   )classify)	colormaps)colorszThe 'folium>=0.12', 'matplotlib' and 'mapclassify' packages are required for 'explore()'. You can install them using 'conda install -c conda-forge "folium>=0.12" matplotlib mapclassify' or 'pip install "folium>=0.12" matplotlib mapclassify'.TF
LinearRingc                     t        |       S Nr   )gs    r#   <lambda>z_explore.<locals>.<lambda>@  s
    jm r%   Simpler   i  objectstringr            r   'z.' cannot be specified in 'map_kwds'. Use the '=z' argument instead.r   r      z{r})scale_factor)r   control_scaletilesattrwidthheightzeThe GeoSeries you are attempting to plot is composed of empty geometries. Nothing has been displayed.)
stacklevelz@The GeoDataFrame and given column have different number of rows.__plottable_columnz=Cannot specify 'categories' when column has categorical dtype)
categoriestab20)r    r!   zo'cmap' is invalid. For categorical plots, pass either valid named matplotlib colormap or a list-like of colors.ki  UserDefined)bins   fillOpacityg      ?weightstyle_functionz%'style_function' has to be a callablec                     i S r+    xs    r#   	_no_stylez_explore.<locals>._no_style  s    Ir%   c                 4    d| d      i}i | |       S )N	fillColor
propertiesrI   )rK   
base_stylecolor
style_kwdsstyle_kwds_functions     r#   _style_colorz_explore.<locals>._style_color  s?    <!7 
 )!, r%   )geometryrQ   __folium_colorc                 B    | d   d   | d   d   d}i | |       S NrO   rV   )rN   rQ   rI   )rK   rP   rR   rS   s     r#   _style_columnz_explore.<locals>._style_column3  sM    %&|_5E%F!"<1A!B" %"J
$-a0 r%   c                 6    | d   d   d}i | |       S rX   rI   )rK   rP   stroke_colorrR   rS   s     r#   _style_strokez_explore.<locals>._style_strokeA  sC    %&|_5E%F!-" %"J
$-a0 r%   c                     i  |       S r+   rI   )rK   rR   rS   s    r#   _style_defaultz _explore.<locals>._style_defaultO  s    ;j;$7$:;;r%   g      ?c                     i S r+   rI   )rK   highlight_kwdss    r#   _style_highlightz"_explore.<locals>._style_highlightX  s    %n%%r%   circle_markermarkercircleradiusfillzKOnly 'marker', 'circle', and 'circle_marker' are supported as marker valuesrU   )columnstooltippopupfeaturesrO   z\{{2,}c                 0    d| j                  d      z   dz   S )Nz	{% raw %}r   z{% endraw %})grouprJ   s    r#   r-   z_explore.<locals>.<lambda>  s    kAGGAJ6G r%   )rh   ri   rc   rG   highlight_function captionlabelNaNcolorbar
max_labelsscale)vminvmaxro   indexfmtz{:.2f}labelsinterval   )ru   rv   ro   )NNrI   )krebrancafoliummatplotlib.pyplotpyplotmapclassifyr&   
matplotlibr'   r(   ImportErrorModuleNotFoundErrorxyzservicescopy	geom_typeanyrU   apply
isinstance	geopandas	GeoSeriesto_framer   equalsto_crsrg   r   uniondtypeslenastyperw   pd
MultiIndexdtypetotal_boundspopnpisnanallr   keys_MAP_KWARGS
ValueErrorstr	providers
query_nameTileProviderhtml_attributionget	build_urlMap
fit_boundsis_emptywarningswarnUserWarningapitypesis_list_likeshapeCategoricalDtypeis_object_dtypeis_bool_dtypeis_string_dtypeisnaCategoricalr?   apply_along_axisto_hexcodesrangeColormaptakecallableminmaxasarrayrA   yblinspaceGeoDataFramelocMarkerCircleCircleMarkeritemsnamedropreset_index_tooltip_popup__geo_interface__subGeoJsonadd_toto_listtolistappend_categorical_legendrC   colormapStepColormapget_legend_classesColorMapNLinearColormap	add_child)VdfcolumncmaprQ   mr9   r:   rh   ri   	highlightcategoricallegendschemerA   ru   rv   r;   r<   r?   classification_kwdsr8   marker_typemarker_kwdsrR   r`   missing_kwdstooltip_kwds
popup_kwdslegend_kwdsmap_kwdskwargsr$   r}   bcr   pltr&   r(   r   HAS_XYZSERVICESgdf
rings_maskcjson_not_supported_colsboundsr   rK   yfitimap_kwdnan_idxcolumn_namecatr   legend_colorsbinningrC   rL   rT   rG   	nan_colorrY   r\   r^   ra   rm   rc   r   valnon_active_geomsfeature_collectionfeaturepropro   cbarcolormap_kwds	cb_colorsrw   rr   rx   show_intervalmp_cmapr"   r[   rS   sV      `                   ``                                                          @@@r#   _explorer	  "   s   hA
'(.%  '')C -J~~#&<<
#;#A#A#$
Z  #y**+lln
ww uWW^^D!jj "kk25++>Q	 Q	(>eCKK

h./0  "#a'jj/FG!!X+GHcii/		*syy(/JII$$X.	 	y!!::j$/BHHV$4$8$8$:fQi+,AfQi+,A1vHv{{},C  	AH} s   !s!HQK=0CE 	

%+[[]Ga;6Fq&)|G

 %%'11<<UCE %!9!9:#t)?)?X-+099Z+CHZ(X-+099Z+DHZ(U;FJJ 
'
 
 LL6!9fQi06!9fQi2HIJ
||H		
  "

7D!" G66<<$$V,6{ciil* V  3#)K $F))2+>+>?% S  KFFLL((V5vv||))#f+6vv||++CK8K''#f+&..VgX!6:NCCNN#A4WD s}}&++MM$TaSYYG
 !# 3 3MM1&6tuUVx&X!
 D&//2++FMM1d399oN " 3 3FMM1d5QR8n U **40s4y=1D	>A#56Dcii0 "eAh 7 !J 
 d^&(j1T!W1E )-3v;??$$D(,3v;??$$D !&.*,'11/0',"JJs6{G845vAT ++MM$TgiiWZZP {{4s3AB7"JJs6{G845}4 ++MM$TcwzzJ J&$'
=!z! 
8:%()9:+,DEE'(	 ( uc"3	 6 67$ *N#y223,,c:"w{{}(,,Wd;	(1$%6;"223(-$%%>>'48L	 "/	 "/	< (.,0N=)	& .! %F+s#(""V]]1[1FH$"V]]1[1FO+$/OOHa$@K!"-//&$"?K(V((7;7F-  #y--. "jjJ6==?
cts||000 
 

 hh/h0 #y--.99>>%//#C GSILIwsAjA
,,


 5 5
56  &j1 L) 	D',/5s;.0ffGL)$//%d+	 FNN%-  fQi &*> >&B//)W5//1J)002M{{}!!,"2"27E"BC$$Y/7JFX HW ??:t4DM{*.9ool.Kl+//MM$TgiiU799EUV	
 "w5!%)<)<)> > $7r{{77! !! '#  ( H &//%:C;.%0%:
%,%?%?%D
(3
E(J,;E)Fa!Ab')FJ)F{{}")),*:*:7E*JK$&IIi$C	'7J	J dBKK$8$89#H.t4G " 3 3q'%		2B*C!I
 yy2~#=2;;#=#=%$!%!%$+	$
 ,$ $<2;;#;#;%$!%!%$+	$
 ,$ ;;=Y'2 0 0% @AI; H%H] ,- 
H
 	

 ,-   , 	? H@ H " J 2n
p *GsX   $z0 { {&7
{+ {0{0-{5 |'|
|0{{#"{#5	||c                 <   ddl }|du s||dk(  ry|du r>|j                  j                  |j                  j                        j                         }ndt        |t              rA|j                  j                  |j                  j                        j                         d| }nt        |t              r|g}dD ]  }||v s|j                  |        t        t        t        |            }| dk(  r |j                  |fi |S | dk(  r |j                  |fi |S y)zGet tooltip or popup.r   NFT)r>   rV   rh   ri   )r   rg   r   rU   r   r   r   intr   removelistmapGeoJsonTooltipGeoJsonPopup)typefieldsr   kwdsr   fields         r#   r   r     s    &.FaKT>[[%%cll&7&78@@BF$[[%%cll&7&78@@B7FKF$XF9 !F?MM% !
 #c6"#Fy$v$$V4t44	"v""62T22 
r%   c                    d}ddl }|j                  j                         }|j                  j                  |      |_        | j                         j                  |       d| d| d}t        ||      D ]  \  }}	|d|	 d| d	z  } |d
z  }|j                  j                  |d      }| j                         j                  j                  |       y)a;  Add categorical legend to a map.

    The implementation is using the code originally written by Michel Metran
    (@michelmetran) and released on GitHub
    (https://github.com/michelmetran/package_folium) under MIT license.

    Copyright (c) 2020 Michel Metran

    Parameters
    ----------
    m : folium.Map
        Existing map instance on which to draw the plot
    title : str
        title of the legend (e.g. column name)
    categories : list-like
        list of categories
    colors : list-like
        list of colors (in the same order as categories)
    aI  
    {% macro header(this, kwargs) %}
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script>$( function() {
        $( ".maplegend" ).draggable({
            start: function (event, ui) {
                $(this).css({
                    right: "auto",
                    top: "auto",
                    bottom: "auto"
                });
            }
        });
    });
    </script>
    <style type='text/css'>
      .maplegend {
        position: absolute;
        z-index:9999;
        background-color: rgba(255, 255, 255, .8);
        border-radius: 5px;
        box-shadow: 0 0 15px rgba(0,0,0,0.2);
        padding: 10px;
        font: 12px/14px Arial, Helvetica, sans-serif;
        right: 10px;
        bottom: 20px;
      }
      .maplegend .legend-title {
        text-align: left;
        margin-bottom: 5px;
        font-weight: bold;
        }
      .maplegend .legend-scale ul {
        margin: 0;
        margin-bottom: 0px;
        padding: 0;
        float: left;
        list-style: none;
        }
      .maplegend .legend-scale ul li {
        list-style: none;
        margin-left: 0;
        line-height: 16px;
        margin-bottom: 2px;
        }
      .maplegend ul.legend-labels li span {
        display: block;
        float: left;
        height: 14px;
        width: 14px;
        margin-right: 5px;
        margin-left: 0;
        border: 0px solid #ccc;
        }
      .maplegend .legend-source {
        color: #777;
        clear: both;
        }
      .maplegend a {
        color: #777;
        }
    </style>
    {% endmacro %}
    r   Nz
    <div id='maplegend z7' class='maplegend'>
        <div class='legend-title'>zP</div>
        <div class='legend-scale'>
            <ul class='legend-labels'>z-
                <li><span style='background:z	'></span>z</li>z1
            </ul>
        </div>
    </div>
    r   )
r~   elementMacroElementTemplate	_templateget_rootr   zipElementhtml)
r   titler?   r(   headr   macrobodyrp   rQ   s
             r#   r   r     s    *?D@  JJ##%Ejj))$/EOJJL5!w ##(' *'*D J/ Lu --2G9UG5L 	LL 	  D ::dH-DJJL%r%   c                 6    t        | f|||||||||	|
|||d|S )u  Interactive map based on GeoPandas and folium/leaflet.js.

    Generate an interactive leaflet map based on :class:`~geopandas.GeoSeries`

    Parameters
    ----------
    color : str, array-like (default None)
        Named color or a list-like of colors (named or hex).
    m : folium.Map (default None)
        Existing map instance on which to draw the plot.
    tiles : str, xyzservices.TileProvider (default 'OpenStreetMap Mapnik')
        Map tileset to use. Can choose from the list supported by folium, query a
        :class:`xyzservices.TileProvider` by a name from ``xyzservices.providers``,
        pass :class:`xyzservices.TileProvider` object or pass custom XYZ URL.
        The current list of built-in providers (when ``xyzservices`` is not available):

        ``["OpenStreetMap", "CartoDB positron", “CartoDB dark_matter"]``

        You can pass a custom tileset to Folium by passing a Leaflet-style URL
        to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``.
        Be sure to check their terms and conditions and to provide attribution with
        the ``attr`` keyword.
    attr : str (default None)
        Map tile attribution; only required if passing custom tile URL.
    highlight : bool (default True)
        Enable highlight functionality when hovering over a geometry.
    width : pixel int or percentage string (default: '100%')
        Width of the folium :class:`~folium.folium.Map`. If the argument
        m is given explicitly, width is ignored.
    height : pixel int or percentage string (default: '100%')
        Height of the folium :class:`~folium.folium.Map`. If the argument
        m is given explicitly, height is ignored.
    control_scale : bool, (default True)
        Whether to add a control scale on the map.
    marker_type : str, folium.Circle, folium.CircleMarker, folium.Marker (default None)
        Allowed string options are ('marker', 'circle', 'circle_marker'). Defaults to
        folium.Marker.
    marker_kwds: dict (default {})
        Additional keywords to be passed to the selected ``marker_type``, e.g.:

        radius : float
            Radius of the circle, in meters (for ``'circle'``) or pixels
            (for ``circle_marker``).
        icon : folium.map.Icon
            the :class:`folium.map.Icon` object to use to render the marker.
        draggable : bool (default False)
            Set to True to be able to drag the marker around the map.

    style_kwds : dict (default {})
        Additional style to be passed to folium ``style_function``:

        stroke : bool (default True)
            Whether to draw stroke along the path. Set it to ``False`` to
            disable borders on polygons or circles.
        color : str
            Stroke color
        weight : int
            Stroke width in pixels
        opacity : float (default 1.0)
            Stroke opacity
        fill : boolean (default True)
            Whether to fill the path with color. Set it to ``False`` to
            disable filling on polygons or circles.
        fillColor : str
            Fill color. Defaults to the value of the color option
        fillOpacity : float (default 0.5)
            Fill opacity.
        style_function : callable
            Function mapping a GeoJson Feature to a style ``dict``.

            * Style properties :func:`folium.vector_layers.path_options`
            * GeoJson features :class:`GeoSeries.__geo_interface__`

            e.g.::

                lambda x: {"color":"red" if x["properties"]["gdp_md_est"]<10**6
                                             else "blue"}


        Plus all supported by :func:`folium.vector_layers.path_options`. See the
        documentation of :class:`folium.features.GeoJson` for details.

    highlight_kwds : dict (default {})
        Style to be passed to folium highlight_function. Uses the same keywords
        as ``style_kwds``. When empty, defaults to ``{"fillOpacity": 0.75}``.
    map_kwds : dict (default {})
        Additional keywords to be passed to folium :class:`~folium.folium.Map`,
        e.g. ``dragging``, or ``scrollWheelZoom``.

    **kwargs : dict
        Additional options to be passed on to the folium.

    Returns
    -------
    m : folium.folium.Map
        folium :class:`~folium.folium.Map` instance

    )rQ   r   r9   r:   r   r;   r<   r8   r   r   rR   r`   r   )r	  )srQ   r   r9   r:   r   r;   r<   r8   r   r   rR   r`   r   r   s                  r#   _explore_geoseriesr$    sK    f 	
#%  r%   )r   
statisticsr   numpyr   pandasr   pandas.api.typesr   shapely.geometryr   r   r   r	  r   r   r$  rI   r%   r#   <module>r*     s        4 ' 0 	


	
		
=Vr36o&h 

	
Cr%   