
    Dh                     @    S SK Jr  S SKJr  S SKJr   " S S\\5      rg)    )MacroElement)
JSCSSMixin)Templatec                   \   ^  \ rS rSrSr\" S5      rS/rS/r        SU 4S jjr	Sr
U =r$ )	Draw   a  
Vector drawing and editing plugin for Leaflet.

Parameters
----------
export : bool, default False
    Add a small button that exports the drawn shapes as a geojson file.
feature_group : FeatureGroup, optional
    The FeatureGroup object that will hold the editable figures. This can
    be used to initialize the Draw plugin with predefined Layer objects.
filename : string, default 'data.geojson'
    Name of geojson file
position : {'topleft', 'toprigth', 'bottomleft', 'bottomright'}
    Position of control.
    See https://leafletjs.com/reference.html#control
show_geometry_on_click : bool, default True
    When True, opens an alert with the geometry description on click.
draw_options : dict, optional
    The options used to configure the draw toolbar. See
    http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#drawoptions
edit_options : dict, optional
    The options used to configure the edit toolbar. See
    https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#editpolyoptions
on : dict, optional
    Event handlers to attach to the created layer. Pass a mapping from the
    names of the events to their `JsCode` handlers.

Examples
--------
>>> m = folium.Map()
>>> Draw(
...     export=True,
...     filename="my_data.geojson",
...     show_geometry_on_click=False,
...     position="topleft",
...     draw_options={"polyline": {"allowIntersection": False}},
...     edit_options={"poly": {"allowIntersection": False}},
...     on={
...         "click": JsCode(
...             """
...         function(event) {
...            alert(JSON.stringify(this.toGeoJSON()));
...         }
...     """
...         )
...     },
... ).add_to(m)

For more info please check
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html

ae  
        {% macro html(this, kwargs) %}
            {% if this.export %}
            <style>
                #export {
                    position: absolute;
                    top: 5px;
                    right: 10px;
                    z-index: 999;
                    background: white;
                    color: black;
                    padding: 6px;
                    border-radius: 4px;
                    font-family: 'Helvetica Neue';
                    cursor: pointer;
                    font-size: 12px;
                    text-decoration: none;
                    top: 90px;
                }
            </style>
            <a href='#' id='export'>Export</a>
            {% endif %}
        {% endmacro %}

        {% macro script(this, kwargs) %}
            var options = {
              position: {{ this.position|tojson }},
              draw: {{ this.draw_options|tojson }},
              edit: {{ this.edit_options|tojson }},
            }
            {%- if this.feature_group  %}
                var drawnItems_{{ this.get_name() }} =
                    {{ this.feature_group.get_name() }};
            {%- else %}
                // FeatureGroup is to store editable layers.
                var drawnItems_{{ this.get_name() }} =
                    new L.featureGroup().addTo(
                        {{ this._parent.get_name() }}
                    );
            {%- endif %}

            options.edit.featureGroup = drawnItems_{{ this.get_name() }};
            var {{ this.get_name() }} = new L.Control.Draw(
                options
            ).addTo( {{this._parent.get_name()}} );
            {{ this._parent.get_name() }}.on(L.Draw.Event.CREATED, function(e) {
                var layer = e.layer,
                    type = e.layerType;
                var coords = JSON.stringify(layer.toGeoJSON());
                {%- if this.show_geometry_on_click %}
                layer.on('click', function() {
                    alert(coords);
                    console.log(coords);
                });
                {%- endif %}

                {%- for event, handler in this.on.items()   %}
                layer.on(
                    "{{event}}",
                    {{handler}}
                );
                {%- endfor %}
                drawnItems_{{ this.get_name() }}.addLayer(layer);
            });
            {{ this._parent.get_name() }}.on('draw:created', function(e) {
                drawnItems_{{ this.get_name() }}.addLayer(e.layer);
            });

            {% if this.export %}
            document.getElementById('export').onclick = function(e) {
                var data = drawnItems_{{ this.get_name() }}.toGeoJSON();
                var convertedData = 'text/json;charset=utf-8,'
                    + encodeURIComponent(JSON.stringify(data));
                document.getElementById('export').setAttribute(
                    'href', 'data:' + convertedData
                );
                document.getElementById('export').setAttribute(
                    'download', {{ this.filename|tojson }}
                );
            }
            {% endif %}
        {% endmacro %}
        )leaflet_draw_jszIhttps://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js)leaflet_draw_csszJhttps://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.cssc	                    > [         T	U ]  5         SU l        Xl        X l        X0l        X@l        XPl        U=(       d    0 U l        U=(       d    0 U l	        U=(       d    0 U l
        g )NDrawControl)super__init___nameexportfeature_groupfilenamepositionshow_geometry_on_clickdraw_optionsedit_optionson)
selfr   r   r   r   r   r   r   r   	__class__s
            fC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\folium/plugins/draw.pyr   Draw.__init__   sW     	"
*  &<#(.B(.B(    )	r   r   r   r   r   r   r   r   r   )FNzdata.geojsontopleftTNNN)__name__
__module____qualname____firstlineno____doc__r   	_template
default_jsdefault_cssr   __static_attributes____classcell__)r   s   @r   r   r      sY    3j R	TIn	
J	
K # r   r   N)branca.elementr   folium.elementsr   folium.templater   r    r   r   <module>r,      s    ' & $m:| mr   