
    Dh                     x    S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr   " S S	\\5      rg
)    )MacroElement)FeatureGroupGeoJsonTopoJson)
JSCSSMixin)Map)MarkerCluster)Template)remove_emptyc                   j   ^  \ rS rSrSr\" S5      rS/rS/r      S
U 4S jjr	S r
U 4S jrS	rU =r$ )Search   a  
Adds a search tool to your map.

Parameters
----------
layer: GeoJson, TopoJson, FeatureGroup, MarkerCluster class object.
    The map layer to index in the Search view.
search_label: str, optional
    'properties' key in layer to index Search, if layer is GeoJson/TopoJson.
search_zoom: int, optional
    Zoom level to set the map to on match.
    By default zooms to Polygon/Line bounds and points
    on their natural extent.
geom_type: str, default 'Point'
    Feature geometry type. "Point", "Line" or "Polygon"
position: str, default 'topleft'
    Change the position of the search bar, can be:
    'topleft', 'topright', 'bottomright' or 'bottomleft',
placeholder: str, default 'Search'
    Placeholder text inside the Search box if nothing is entered.
collapsed: boolean, default False
    Whether the Search box should be collapsed or not.
**kwargs.
    Assorted style options to change feature styling on match.
    Use the same way as vector layer arguments.

See https://github.com/stefanocudini/leaflet-search for more information.

a  
        {% macro script(this, kwargs) %}
            var {{this.layer.get_name()}}searchControl = new L.Control.Search({
                layer: {{this.layer.get_name()}},
                {% if this.search_label %}
                propertyName: '{{this.search_label}}',
                {% endif %}
                collapsed: {{this.collapsed|tojson|safe}},
                textPlaceholder: '{{this.placeholder}}',
                position:'{{this.position}}',
            {% if this.geom_type == 'Point' %}
                initial: false,
                {% if this.search_zoom %}
                zoom: {{this.search_zoom}},
                {% endif %}
                hideMarkerOnCollapse: true
            {% else %}
                marker: false,
                moveToLocation: function(latlng, title, map) {
                var zoom = {% if this.search_zoom %} {{ this.search_zoom }} {% else %} map.getBoundsZoom(latlng.layer.getBounds()) {% endif %}
                    map.flyTo(latlng, zoom); // access the zoom
                }
            {% endif %}
                });
                {{this.layer.get_name()}}searchControl.on('search:locationfound', function(e) {
                    {{this.layer.get_name()}}.setStyle(function(feature){
                        return feature.properties.style
                    })
                    {% if this.options %}
                    e.layer.setStyle({{ this.options|tojavascript }});
                    {% endif %}
                    if(e.layer._popup)
                        e.layer.openPopup();
                })
                {{this.layer.get_name()}}searchControl.on('search:collapsed', function(e) {
                        {{this.layer.get_name()}}.setStyle(function(feature){
                            return feature.properties.style
                    });
                });
            {{this._parent.get_name()}}.addControl( {{this.layer.get_name()}}searchControl );

        {% endmacro %}
        )zLeaflet.Search.jszLhttps://cdn.jsdelivr.net/npm/leaflet-search@2.9.7/dist/leaflet-search.min.js)zLeaflet.Search.csszMhttps://cdn.jsdelivr.net/npm/leaflet-search@2.9.7/dist/leaflet-search.min.cssc                    > [         T	U ]  5         [        U[        [        [
        [        45      (       d   S5       eXl        X l        X0l	        X@l
        XPl        X`l        Xpl        [        S0 UD6U l        g )Nz]Search can only index FeatureGroup, MarkerCluster, GeoJson, and TopoJson layers at this time. )super__init__
isinstancer   r	   r   r   layersearch_labelsearch_zoom	geom_typepositionplaceholder	collapsedr   options)
selfr   r   r   r   r   r   r   kwargs	__class__s
            hC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\folium/plugins/search.pyr   Search.__init__h   so     	%'=,!QRR 	
	
R
 
(&" &"#-f-    c                     Ub4  U R                   b'  U R                   U;   d   SU R                    SU 35       e[        U R                  [        5      (       d   S5       eg )NzThe label 'z' was not available in z/Search can only be added to folium Map objects.)r   r   _parentr   )r   keyss     r   test_paramsSearch.test_params   sp     1 1 =$$, d//00KD6U, LL#
 
 	=<	= 
r!   c                   > [        U R                  [        5      (       a7  [        U R                  R                  S   S   S   R                  5       5      nO[        U R                  [        5      (       ae  U R                  R                  R                  S5      S   n[        U R                  R                  S   U   S   S   S   R                  5       5      nOS nU R                  US9  [        TU ],  " S	0 UD6  g )
Nfeaturesr   
properties.objects
geometries)r$   r   )r   r   r   tupledatar$   r   object_pathsplitr%   r   render)r   r   r$   obj_namer   s       r   r2   Search.render   s    djj'**4Q7EJJLMD

H--zz--33C8<H

	*84\B1E $&D Dd#  r!   )r   r   r   r   r   r   r   r   )NNPointtopleftr   F)__name__
__module____qualname____firstlineno____doc__r
   	_template
default_jsdefault_cssr   r%   r2   __static_attributes____classcell__)r   s   @r   r   r      sZ    < *	,I^	
J	
K .4=! !r!   r   N)branca.elementr   foliumr   r   r   folium.elementsr   folium.foliumr   folium.pluginsr	   folium.templater
   folium.utilitiesr   r   r   r!   r   <module>rH      s/    ' 2 2 &  ( $ )K!Z K!r!   