o
    PÉf  ã                   @   sR   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 G dd„ deeƒZ
dS )	é    )ÚOptional)ÚMacroElement)ÚTemplate)Ú
JSCSSMixin)Úparse_optionsc                       s`   e Zd ZdZedƒZdgZdgZddddd	i fd
ede	dede
e de	def‡ fdd„Z‡  ZS )ÚGeocoderah  A simple geocoder for Leaflet that by default uses OSM/Nominatim.

    Please respect the Nominatim usage policy:
    https://operations.osmfoundation.org/policies/nominatim/

    Parameters
    ----------
    collapsed: bool, default False
        If True, collapses the search box unless hovered/clicked.
    position: str, default 'topright'
        Choose from 'topleft', 'topright', 'bottomleft' or 'bottomright'.
    add_marker: bool, default True
        If True, adds a marker on the found location.
    zoom: int, default 11, optional
        Set zoom level used for displaying the geocode result, note that this only has an effect when add_marker is set to False. Set this to None to preserve the current map zoom level.
    provider: str, default 'nominatim'
        Defaults to "nominatim", see https://github.com/perliedman/leaflet-control-geocoder/tree/2.4.0/src/geocoders for other built-in providers.
    provider_options: dict, default {}
        For use with specific providers that may require api keys or other parameters.

    For all options see https://github.com/perliedman/leaflet-control-geocoder

    aÞ  
        {% macro script(this, kwargs) %}

            var geocoderOpts_{{ this.get_name() }} = {{ this.options|tojson }};

            // note: geocoder name should start with lowercase
            var geocoderName_{{ this.get_name() }} = geocoderOpts_{{ this.get_name() }}["provider"];

            var customGeocoder_{{ this.get_name() }} = L.Control.Geocoder[ geocoderName_{{ this.get_name() }} ](
                geocoderOpts_{{ this.get_name() }}['providerOptions']
            );
            geocoderOpts_{{ this.get_name() }}["geocoder"] = customGeocoder_{{ this.get_name() }};

            L.Control.geocoder(
                geocoderOpts_{{ this.get_name() }}
            ).on('markgeocode', function(e) {
                var zoom = geocoderOpts_{{ this.get_name() }}['zoom'] || {{ this._parent.get_name() }}.getZoom();
                {{ this._parent.get_name() }}.setView(e.geocode.center, zoom);
            }).addTo({{ this._parent.get_name() }});

        {% endmacro %}
    )zControl.Geocoder.jszChttps://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js)zControl.Geocoder.csszDhttps://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.cssFÚtoprightTé   Ú	nominatimÚ	collapsedÚpositionÚ
add_markerÚzoomÚproviderÚprovider_optionsc              	      s2   t ƒ  ¡  d| _td||||||dœ|¤Ž| _d S )Nr   )r   r   Údefault_mark_geocoder   r   r   © )ÚsuperÚ__init__Ú_namer   Úoptions)Úselfr   r   r   r   r   r   Úkwargs©Ú	__class__r   úc/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/folium/plugins/geocoder.pyr   I   s   

úùzGeocoder.__init__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	_templateÚ
default_jsÚdefault_cssÚboolÚstrr   ÚintÚdictr   Ú__classcell__r   r   r   r   r   
   s8    ÿÿÿ	ùþýüûúùr   N)Útypingr   Úbranca.elementr   Újinja2r   Úfolium.elementsr   Úfolium.utilitiesr   r   r   r   r   r   Ú<module>   s    