geemap/geemap.py
def ee_tile_layer(
    ee_object, vis_params={}, name="Layer untitled", shown=True, opacity=1.0
):
    """Converts and Earth Engine layer to ipyleaflet TileLayer.

    Args:
        ee_object (Collection|Feature|Image|MapId): The object to add to the map.
        vis_params (dict, optional): The visualization parameters. Defaults to {}.
        name (str, optional): The name of the layer. Defaults to 'Layer untitled'.
        shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
        opacity (float, optional): The layer's opacity represented as a number between 0 and 1. Defaults to 1.
    """

    image = None

    if (
        not isinstance(ee_object, ee.Image)
        and not isinstance(ee_object, ee.ImageCollection)
        and not isinstance(ee_object, ee.FeatureCollection)
        and not isinstance(ee_object, ee.Feature)
        and not isinstance(ee_object, ee.Geometry)
    ):
        err_str = "\n\nThe image argument in 'addLayer' function must be an instance of one of ee.Image, ee.Geometry, ee.Feature or ee.FeatureCollection."
        raise AttributeError(err_str)

    if (
        isinstance(ee_object, ee.geometry.Geometry)
        or isinstance(ee_object, ee.feature.Feature)
        or isinstance(ee_object, ee.featurecollection.FeatureCollection)
    ):
        features = ee.FeatureCollection(ee_object)

        width = 2

        if "width" in vis_params:
            width = vis_params["width"]

        color = "000000"

        if "color" in vis_params:
            color = vis_params["color"]

        image_fill = features.style(**{"fillColor": color}).updateMask(
            ee.Image.constant(0.5)
        )
        image_outline = features.style(
            **{"color": color, "fillColor": "00000000", "width": width}
        )

        image = image_fill.blend(image_outline)
    elif isinstance(ee_object, ee.image.Image):
        image = ee_object
    elif isinstance(ee_object, ee.imagecollection.ImageCollection):
        image = ee_object.mosaic()

    map_id_dict = ee.Image(image).getMapId(vis_params)
    tile_layer = ipyleaflet.TileLayer(
        url=map_id_dict["tile_fetcher"].url_format,
        attribution="Google Earth Engine",
        name=name,
        opacity=opacity,
        visible=shown,
    )
    return tile_layer
Converts and Earth Engine layer to ipyleaflet TileLayer.

    Args:
        ee_object (Collection|Feature|Image|MapId): The object to add to the map.
        vis_params (dict, optional): The visualization parameters. Defaults to {}.
        name (str, optional): The name of the layer. Defaults to 'Layer untitled'.
        shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
        opacity (float, optional): The layer's opacity represented as a number between 0 and 1. Defaults to 1.
    
Converts and Earth Engine layer to ipyleaflet TileLayer.
Converts and Earth Engine layer to ipyleaflet TileLayer .
def ee_tile_layer(
    ee_object, vis_params={}, name="Layer untitled", shown=True, opacity=1.0
):
    image = None
    if (
        not isinstance(ee_object, ee.Image)
        and not isinstance(ee_object, ee.ImageCollection)
        and not isinstance(ee_object, ee.FeatureCollection)
        and not isinstance(ee_object, ee.Feature)
        and not isinstance(ee_object, ee.Geometry)
    ):
        err_str = "\n\nThe image argument in 'addLayer' function must be an instance of one of ee.Image, ee.Geometry, ee.Feature or ee.FeatureCollection."
        raise AttributeError(err_str)
    if (
        isinstance(ee_object, ee.geometry.Geometry)
        or isinstance(ee_object, ee.feature.Feature)
        or isinstance(ee_object, ee.featurecollection.FeatureCollection)
    ):
        features = ee.FeatureCollection(ee_object)
        width = 2
        if "width" in vis_params:
            width = vis_params["width"]
        color = "000000"
        if "color" in vis_params:
            color = vis_params["color"]
        image_fill = features.style(**{"fillColor": color}).updateMask(
            ee.Image.constant(0.5)
        )
        image_outline = features.style(
            **{"color": color, "fillColor": "00000000", "width": width}
        )
        image = image_fill.blend(image_outline)
    elif isinstance(ee_object, ee.image.Image):
        image = ee_object
    elif isinstance(ee_object, ee.imagecollection.ImageCollection):
        image = ee_object.mosaic()
    map_id_dict = ee.Image(image).getMapId(vis_params)
    tile_layer = ipyleaflet.TileLayer(
        url=map_id_dict["tile_fetcher"].url_format,
        attribution="Google Earth Engine",
        name=name,
        opacity=opacity,
        visible=shown,
    )
    return tile_layer
def ee_tile_layer ( ee_object , vis_params = { } , name = "Layer untitled" , shown = True , opacity = 1.0 ) : image = None if ( not isinstance ( ee_object , ee . Image ) and not isinstance ( ee_object , ee . ImageCollection ) and not isinstance ( ee_object , ee . FeatureCollection ) and not isinstance ( ee_object , ee . Feature ) and not isinstance ( ee_object , ee . Geometry ) ) : err_str = "\n\nThe image argument in 'addLayer' function must be an instance of one of ee.Image, ee.Geometry, ee.Feature or ee.FeatureCollection." raise AttributeError ( err_str ) if ( isinstance ( ee_object , ee . geometry . Geometry ) or isinstance ( ee_object , ee . feature . Feature ) or isinstance ( ee_object , ee . featurecollection . FeatureCollection ) ) : features = ee . FeatureCollection ( ee_object ) width = 2 if "width" in vis_params : width = vis_params [ "width" ] color = "000000" if "color" in vis_params : color = vis_params [ "color" ] image_fill = features . style ( ** { "fillColor" : color } ) . updateMask ( ee . Image . constant ( 0.5 ) ) image_outline = features . style ( ** { "color" : color , "fillColor" : "00000000" , "width" : width } ) image = image_fill . blend ( image_outline ) elif isinstance ( ee_object , ee . image . Image ) : image = ee_object elif isinstance ( ee_object , ee . imagecollection . ImageCollection ) : image = ee_object . mosaic ( ) map_id_dict = ee . Image ( image ) . getMapId ( vis_params ) tile_layer = ipyleaflet . TileLayer ( url = map_id_dict [ "tile_fetcher" ] . url_format , attribution = "Google Earth Engine" , name = name , opacity = opacity , visible = shown , ) return tile_layer
Converts and Earth Engine layer to ipyleaflet TileLayer.
Converts and Earth Engine layer to ipyleaflet TileLayer .
"""Converts and Earth Engine layer to ipyleaflet TileLayer.

    Args:
        ee_object (Collection|Feature|Image|MapId): The object to add to the map.
        vis_params (dict, optional): The visualization parameters. Defaults to {}.
        name (str, optional): The name of the layer. Defaults to 'Layer untitled'.
        shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
        opacity (float, optional): The layer's opacity represented as a number between 0 and 1. Defaults to 1.
    """
ee_object
The object to add to the map.
The object to add to the map .
vis_params
The visualization parameters. Defaults to {}.
The visualization parameters . Defaults to {} .
{}
name
The name of the layer. Defaults to 'Layer untitled'.
The name of the layer . Defaults to ' Layer untitled ' .
'Layer untitled'
shown
A flag indicating whether the layer should be on by default. Defaults to True.
A flag indicating whether the layer should be on by default . Defaults to True .
True
opacity
The layer's opacity represented as a number between 0 and 1. Defaults to 1.
The layer ' s opacity represented as a number between 0 and 1 . Defaults to 1 .
1