o
    Pf                     @   sb   d dl mZmZ 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 )
    )FigureMacroElement)Template)
JSCSSMixin)Map)LayerControl)	deep_copyc                       s^   e Zd ZdZedZdgZd fdd	Zdd	 Zdd
dZ	 fddZ
dd Zdd Z  ZS )DualMapa  Create two maps in the same window.

    Adding children to this objects adds them to both maps. You can access
    the individual maps with `DualMap.m1` and `DualMap.m2`.

    Uses the Leaflet plugin Sync: https://github.com/jieter/Leaflet.Sync

    Parameters
    ----------
    location: tuple or list, optional
        Latitude and longitude of center point of the maps.
    layout : {'horizontal', 'vertical'}
        Select how the two maps should be positioned. Either horizontal (left
        and right) or vertical (top and bottom).
    **kwargs
        Keyword arguments are passed to the two Map objects.

    Examples
    --------
    >>> # DualMap accepts the same arguments as Map:
    >>> m = DualMap(location=(0, 0), tiles="cartodbpositron", zoom_start=5)
    >>> # Add the same marker to both maps:
    >>> Marker((0, 0)).add_to(m)
    >>> # The individual maps are attributes called `m1` and `m2`:
    >>> Marker((0, 1)).add_to(m.m1)
    >>> LayerControl().add_to(m)
    >>> m.save("map.html")

    z
        {% macro script(this, kwargs) %}
            {{ this.m1.get_name() }}.sync({{ this.m2.get_name() }});
            {{ this.m2.get_name() }}.sync({{ this.m1.get_name() }});
        {% endmacro %}
    )zLeaflet.SynczAhttps://cdn.jsdelivr.net/gh/jieter/Leaflet.Sync/L.Map.Sync.min.jsN
horizontalc              	      s   t    dD ]}||vsJ d| dq|dvr"td| d|dkr(dnd	}|dkr0d	nd}td|||d
d
dd|| _td||||dkrLdnd
|dkrSd
nddd|| _t }|| j || j ||  g | _g | _	d S )N)widthheightlefttoppositionz	Argument z cannot be used with  DualMap.)r
   verticalz(Undefined option for argument `layout`: z(. Use either 'horizontal' or 'vertical'.r
   z50%z100%z0%absolute)locationr   r   r   r   r    )
super__init__
ValueErrorr   m1m2r   	add_childchildren_for_m2children_for_m2_copied)selfr   layoutkwargskeyr   r   figure	__class__r   c/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/folium/plugins/dual_map.pyr   9   sF   

		

zDualMap.__init__c                 K   sH   | j du r| t  | j jdi |}d| _ |S | j jdi |}|S )z,Displays the HTML Map in a Jupyter notebook.Nr   )_parentadd_tor   _repr_html_)r   r   outr   r   r#   r&   ^   s   
zDualMap._repr_html_c                 C   s:   | j ||| |du rt| jj}| j|||f dS )z@Add object `child` to the first map and store it for the second.N)r   r   lenr   	_childrenr   append)r   childnameindexr   r   r#   r   h   s   zDualMap.add_childc                    sv   t  jdi | | jD ],\}}}|j| jv rqt|}t|tr%|  | j	
||| |  | j|j qd S )Nr   )r   renderr   _idr   r   
isinstancer   resetr   r   r*   )r   r   r+   r,   r-   
child_copyr!   r   r#   r.   o   s   
zDualMap.renderc                 O   s&   | j | jfD ]
}|j|i | qd S N)r   r   
fit_bounds)r   argsr   mr   r   r#   r4   ~   s   zDualMap.fit_boundsc                 G   s    | j | jfD ]}|j|  qd S r3   )r   r   keep_in_front)r   r5   r6   r   r   r#   r7      s   zDualMap.keep_in_front)Nr
   )NN)__name__
__module____qualname____doc__r   	_template
default_jsr   r&   r   r.   r4   r7   __classcell__r   r   r!   r#   r	   
   s    
%

r	   N)branca.elementr   r   jinja2r   folium.elementsr   folium.foliumr   
folium.mapr   folium.utilitiesr   r	   r   r   r   r#   <module>   s    