
    /_iG                    @   U d Z ddlmZ ddlZddlZddlmZmZmZm	Z	 ddl
mZmZ ddlmZmZ ddlmZ ddlmZmZmZmZ dd	lmZmZmZmZmZ dd
lmZ ddlm Z! ddl"m#Z# erddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+  e,ejZ                        Z.de/d<   h dZ0de/d<   h dZ1de/d<   dZ2de/d<   dZ3de/d<   dZ4de/d<   g dZ5de/d<    G d  d!      Z6	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)d"Z7	 	 	 	 	 	 	 	 	 	 d*d#Z8	 	 	 	 	 	 	 	 d+d$Z9	 	 	 	 	 	 	 	 d,d%Z:	 	 	 	 	 	 	 	 	 	 d-d&Z;d.d'Z<	 	 	 	 	 	 d/d(Z=y)0z+A wrapper for simple PyDeck scatter charts.    )annotationsN)TYPE_CHECKINGAnyFinalcast)configdataframe_util)make_deprecated_name_warningshow_deprecation_warning)deck_gl_json_chart)ColorIntColorTupleis_color_liketo_int_color_tuple)HeightWithoutContentLayoutConfigWidthWithoutContentvalidate_heightvalidate_width)StreamlitAPIException)DeckGlJsonChart)gather_metrics)
Collection)	DataFrame)Data)DeltaGeneratorzFinal[dict[str, Any]]_DEFAULT_MAP>   LATlatLATITUDElatituder   _DEFAULT_LAT_COL_NAMES>   LONlon	LONGITUDE	longitude_DEFAULT_LON_COL_NAMES)      r      _DEFAULT_COLORd   _DEFAULT_SIZE   _DEFAULT_ZOOM_LEVEL)ih     Z   -   g     6@g     &@g     @g/$@g"~?g"~?gI+?gI+?gI+?gI+?gI+?gI+?g{Gzt?g~jth?gMbP?gMb@?gMb0?_ZOOM_LEVELSc                  z    e Zd Z ed      	 dddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	d       Zed
d       Zy)MapMixinmapNstretchi  )r!   r&   colorsizezoomwidthheightuse_container_widthc          	        |	t        t        ddddd      d       |	rd}t        |d	       t        |d	       t	               }
t        ||||||      }t        |
|       t        ||
      }| j                  j                  d|
|      S )a  Display a map with a scatterplot overlaid onto it.

        This is a wrapper around ``st.pydeck_chart`` to quickly create
        scatterplot charts on top of a map, with auto-centering and auto-zoom.

        When using this command, a service called Carto_ provides the map tiles to render
        map content. If you're using advanced PyDeck features you may need to obtain
        an API key from Carto first. You can do that as
        ``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
        environment variable. See `PyDeck's documentation`_ for more information.

        Another common provider for map tiles is Mapbox_. If you prefer to use that,
        you'll need to create an account at https://mapbox.com and specify your Mapbox
        key when creating the ``pydeck.Deck`` object. You can do that as
        ``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
        environment variable.

        .. _Carto: https://carto.com
        .. _Mapbox: https://mapbox.com
        .. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html

        Carto and Mapbox are third-party products and Streamlit accepts no responsibility
        or liability of any kind for Carto or Mapbox, or for any content or information
        made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
        their respective Terms of Use.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            The data to be plotted.

        latitude : str or None
            The name of the column containing the latitude coordinates of
            the datapoints in the chart.

            If None, the latitude data will come from any column named 'lat',
            'latitude', 'LAT', or 'LATITUDE'.

        longitude : str or None
            The name of the column containing the longitude coordinates of
            the datapoints in the chart.

            If None, the longitude data will come from any column named 'lon',
            'longitude', 'LON', or 'LONGITUDE'.

        color : str or tuple or None
            The color of the circles representing each datapoint.

            Can be:

            - None, to use the default color.
            - A hex string like "#ffaa00" or "#ffaa0088".
            - An RGB or RGBA tuple with the red, green, blue, and alpha
              components specified as ints from 0 to 255 or floats from 0.0 to
              1.0.
            - The name of the column to use for the color. Cells in this column
              should contain colors represented as a hex string or color tuple,
              as described above.

        size : str or float or None
            The size of the circles representing each point, in meters.

            This can be:

            - None, to use the default size.
            - A number like 100, to specify a single size to use for all
              datapoints.
            - The name of the column to use for the size. This allows each
              datapoint to be represented by a circle of a different size.

        zoom : int
            Zoom level as specified in
            https://wiki.openstreetmap.org/wiki/Zoom_levels.

        width : "stretch" or int
            The width of the chart element. This can be one of the following:

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        height : "stretch" or int
            The height of the chart element. This can be one of the following:

            - An integer specifying the height in pixels: The element has a
              fixed height. If the content is larger than the specified
              height, scrolling is enabled. This is ``500`` by default.
            - ``"stretch"``: The height of the element matches the height of
              its content or the height of the parent container, whichever is
              larger. If the element is not in a parent container, the height
              of the element matches the height of its content.

        use_container_width : bool or None
            Whether to override the map's native width with the width of
            the parent container. This can be one of the following:

            - ``None`` (default): Streamlit will use the map's default behavior.
            - ``True``: Streamlit sets the width of the map to match the
              width of the parent container.
            - ``False``: Streamlit sets the width of the map to fit its
              contents according to the plotting library, up to the width of
              the parent container.

            .. deprecated::
               ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``.

        Examples
        --------
        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        >>>     rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
        >>>     columns=["lat", "lon"],
        >>> )
        >>>
        >>> st.map(df)

        .. output::
           https://doc-map.streamlit.app/
           height: 600px

        You can also customize the size and color of the datapoints:

        >>> st.map(df, size=20, color="#0044ff")

        And finally, you can choose different columns to use for the latitude
        and longitude components, as well as set size and color of each
        datapoint dynamically based on other columns:

        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        ...     {
        ...         "col1": rng(0).standard_normal(1000) / 50 + 37.76,
        ...         "col2": rng(1).standard_normal(1000) / 50 + -122.4,
        ...         "col3": rng(2).standard_normal(1000) * 100,
        ...         "col4": rng(3).standard_normal((1000, 4)).tolist(),
        ...     }
        ... )
        >>>
        >>> st.map(df, latitude="col1", longitude="col2", size="col3", color="col4")

        .. output::
           https://doc-map-color.streamlit.app/
           height: 600px

        r=   r;   z
2025-12-31zqFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, specify an integer width.F)include_st_prefix)show_in_browserr7   )allow_content)r;   r<   r   )layout_config)
r   r
   r   r   DeckGlJsonChartPrototo_deckgl_jsonmarshallr   dg_enqueue)selfdatar!   r&   r8   r9   r:   r;   r<   r=   	map_protodeck_gl_jsonrB   s                U/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/elements/map.pyr6   zMapMixin.mapY   s    V *$,) Q&+ !&
 #! 	uE2e4(*	%dHiudSL)$5@ww )=   
 	
    c                    t        d|       S )zGet our DeltaGenerator.r   )r   )rH   s    rL   rF   zMapMixin.dg!  s     $d++rM   )N)rI   r   r!   
str | Noner&   rO   r8   zNone | str | Colorr9   None | str | floatr:   
int | Noner;   r   r<   r   r=   zbool | Nonereturnr   )rR   r   )__name__
__module____qualname__r   r6   propertyrF    rM   rL   r5   r5   X   s    E E
  $ $$(#'%.'*+/E
E
 	E

 E
 "E
 !E
 E
 #E
 %E
 )E
 
E
 E
N , ,rM   r5   c           	        | t        j                  t              S t        | d      r%| j                  rt        j                  t              S t        j                  |       }t        |d|t              }t        |d|t              }t        ||t              \  }	}
t        ||t              \  }}t        |||
|hD cg c]  }|| c}      }||   }t        |||      }t        ||||      \  }}}t!        j"                  t              }||d   d<   ||d   d<   ||d   d<   dd| d| d	|	d
d||j%                  d      dg|d<   t        j                  |      S c c}w )Nemptyr!   r&   initialViewStater:   ScatterplotLayerz@@=[, ]   metersrecords)z@@typegetPosition	getRadiusradiusMinPixelsradiusUnitsgetFillColorrI   layers)jsondumpsr   hasattrrY   r	   convert_anything_to_pandas_df_get_lat_or_lon_col_namer"   r'   _get_value_and_col_namer-   r+   sorted_convert_color_arg_or_column_get_viewport_detailscopydeepcopyto_dict)rI   r   r$   r9   r8   r:   dflat_col_namelon_col_namesize_argsize_col_name	color_argcolor_col_namecused_columnsconverted_color_arg
center_lat
center_londefaults                      rL   rD   rD   '  s    |zz,''
 tW$**zz,''		5	5d	;B+B
CAWXL+
K4L 6b$NHm 7E> RI~  #L-P	
} 	
L 
L	B6r9nU#8
L,$ D*j mmL)G.8G
+/9G,*.G' )!,r,qA! #/JJy)	

GH ::g=	
s   ;Ec                   t        |t              r|| j                  v r|}nd}|D ]  }|| j                  v s|} n |ndj                  t	        t
        t        |                  }dj                  t	        t
        t        | j                                    }t        d| d| d|       |}t        | |   j                         j                        rt        d| d      |S )z=Returns the column name to be used for latitude or longitude.Nr\   zMap data must contain a z column named: z. Existing columns: zColumn zB is not allowed to contain null values, such as NaN, NaT, or None.)
isinstancestrcolumnsjoinr6   reprrm   listr   anyisnaarray)	rI   human_readable_namecol_name_from_userdefault_col_namescol_namecandidate_col_namerz   formatted_allowed_col_nameformmated_col_namess	            rL   rk   rk   e  s    $c*/AT\\/Q% "" 	ADLL %&"	
 %)-3tVDU=V3W)X&"&))Cd4<<6H,I"J'*+>*?-..BCVBWY  & 4> &&'#hZ  $ $
 	

 OrM   c                l    t        |t              r|| j                  v r|}d| }||fS d}||n|}||fS )a  Take a value_or_name passed in by the Streamlit developer and return a PyDeck
    argument and column name for that property.

    This is used for the size and color properties of the chart.

    Example:
    - If the user passes size=None, this returns the default size value and no column.
    - If the user passes size=42, this returns 42 and no column.
    - If the user passes size="my_col_123", this returns "@@=my_col_123" and "my_col_123".
    z@@=N)r   r   r   )rI   value_or_namedefault_valuer   
pydeck_args        rL   rl   rl     sU    $ -%-4<<*G 8*%
 x	 &3&;]
xrM   c                   d}|vt        | |         dkD  rVt        | |   j                  d         r;| j                  dd|f   j	                  t
              | j                  dd|f<   |}|S t        d| d      |t        |      }|S )aR  Converts color to a format accepted by PyDeck.

    For example:
    - If color_arg is "#fff", then returns (255, 255, 255, 255).
    - If color_col_name is "my_col_123", then it converts everything in column my_col_123 to
      an accepted color format such as (0, 100, 200, 255).

    NOTE: This function mutates the data argument.
    Nr   zColumn "z*" does not appear to contain valid colors.)lenr   iatlocr6   r   r   )rI   rx   ry   color_arg_outs       rL   rn   rn     s     15M!tN#$q(]4;O;S;STU;V-W*.((1n3D*E*I*I"+DHHQ&' "
  (>**TU  
	*95rM   c                .   | |   j                         }| |   j                         }| |   j                         }| |   j                         }||z   dz  }||z   dz  }	t        ||z
        }
t        ||z
        }|t        ||
      }t        |      }|||	fS )z3Auto-set viewport when not fully specified by user.g       @)minmaxabs_get_zoom_level)rI   rt   ru   r:   min_latmax_latmin_lonmax_lonr}   r~   	range_lon	range_latlongitude_distances                rL   ro   ro     s     < $$&G< $$&G< $$&G< $$&GG#s*JG#s*JGg%&IGg%&I| I612Z''rM   c                    t        t        t              dz
        D ]$  }t        |dz      | cxk  rt        |   k  s |c S  & t        S )a9  Get the zoom level for a given distance in degrees.

    See https://wiki.openstreetmap.org/wiki/Zoom_levels for reference.

    Parameters
    ----------
    distance : float
        How many degrees of longitude should fit in the map.

    Returns
    -------
    int
        The zoom level, from 0 to 20.

       )ranger   r3   r/   )distanceis     rL   r   r     sN      3|$q() A<\!_<H =
 rM   c                ^    || _         d| _        t        j                  d      }|r|| _        yy)zMarshall a map proto with the given pydeck JSON specification.

    Layout configuration (width, height, etc.) is handled by the LayoutConfig
    system and not through proto fields.
     zmapbox.tokenN)rg   idr   
get_optionmapbox_token)pydeck_protopydeck_jsonr   s      rL   rE   rE      s3     $LLO$$^4L$0! rM   )rI   r   r   rO   r$   rO   r9   rP   r8   zNone | str | Collection[float]r:   rQ   rR   r   )
rI   r   r   r   r   rO   r   zset[str]rR   r   )rI   r   r   r   r   r   rR   ztuple[str, str | None])rI   r   rx   r   ry   rO   rR   zNone | str | IntColorTuple)
rI   r   rt   r   ru   r   r:   rQ   rR   ztuple[int, float, float])r   floatrR   int)r   rC   r   r   rR   None)>__doc__
__future__r   rp   rg   typingr   r   r   r   	streamlitr   r	   streamlit.deprecation_utilr
   r   streamlit.elementsr   !streamlit.elements.lib.color_utilr   r   r   r   #streamlit.elements.lib.layout_utilsr   r   r   r   r   streamlit.errorsr   #streamlit.proto.DeckGlJsonChart_pb2r   rC   streamlit.runtime.metrics_utilr   collections.abcr   pandasr   streamlit.dataframe_utilr   streamlit.delta_generatorr   dict	EMPTY_MAPr   __annotations__r"   r'   r+   r-   r/   r3   r5   rD   rk   rl   rn   ro   r   rE   rW   rM   rL   <module>r      s   2 "   2 2 , 2   3 W 9* -8 '++=+G+G&H# H !G  F H  H) )u  U e 2L, L,^;
;	; 
; 	;
 *; ; 	;|*
** #*  	*
 	*Z 
     	 :"
"" "  	"J(
(#&(69(AK(((01&11 
1rM   