geemap/geemap.py
def linked_maps(
    rows=2,
    cols=2,
    height="400px",
    ee_objects=[],
    vis_params=[],
    labels=[],
    label_position="topright",
    **kwargs,
):
    """Create linked maps of Earth Engine data layers.

    Args:
        rows (int, optional): The number of rows of maps to create. Defaults to 2.
        cols (int, optional): The number of columns of maps to create. Defaults to 2.
        height (str, optional): The height of each map in pixels. Defaults to "400px".
        ee_objects (list, optional): The list of Earth Engine objects to use for each map. Defaults to [].
        vis_params (list, optional): The list of visualization parameters to use for each map. Defaults to [].
        labels (list, optional): The list of labels to show on the map. Defaults to [].
        label_position (str, optional): The position of the label, can be [topleft, topright, bottomleft, bottomright]. Defaults to "topright".

    Raises:
        ValueError: If the length of ee_objects is not equal to rows*cols.
        ValueError: If the length of vis_params is not equal to rows*cols.
        ValueError: If the length of labels is not equal to rows*cols.

    Returns:
        ipywidget: A GridspecLayout widget.
    """
    grid = widgets.GridspecLayout(rows, cols, grid_gap="0px")
    count = rows * cols

    maps = []

    if len(ee_objects) > 0:
        if len(ee_objects) == 1:
            ee_objects = ee_objects * count
        elif len(ee_objects) < count:
            raise ValueError(f"The length of ee_objects must be equal to {count}.")

    if len(vis_params) > 0:
        if len(vis_params) == 1:
            vis_params = vis_params * count
        elif len(vis_params) < count:
            raise ValueError(f"The length of vis_params must be equal to {count}.")

    if len(labels) > 0:
        if len(labels) == 1:
            labels = labels * count
        elif len(labels) < count:
            raise ValueError(f"The length of labels must be equal to {count}.")

    for i in range(rows):
        for j in range(cols):
            index = i * rows + j
            m = Map(
                height=height,
                lite_mode=True,
                add_google_map=False,
                layout=widgets.Layout(margin="0px", padding="0px"),
                **kwargs,
            )

            if len(ee_objects) > 0:
                m.addLayer(ee_objects[index], vis_params[index], labels[index])

            if len(labels) > 0:
                label = widgets.Label(
                    labels[index], layout=widgets.Layout(padding="0px 5px 0px 5px")
                )
                control = ipyleaflet.WidgetControl(
                    widget=label, position=label_position
                )
                m.add_control(control)

            maps.append(m)
            widgets.jslink((maps[0], "center"), (m, "center"))
            widgets.jslink((maps[0], "zoom"), (m, "zoom"))

            output = widgets.Output()
            with output:
                display(m)
            grid[i, j] = output

    return grid
Create linked maps of Earth Engine data layers.

    Args:
        rows (int, optional): The number of rows of maps to create. Defaults to 2.
        cols (int, optional): The number of columns of maps to create. Defaults to 2.
        height (str, optional): The height of each map in pixels. Defaults to "400px".
        ee_objects (list, optional): The list of Earth Engine objects to use for each map. Defaults to [].
        vis_params (list, optional): The list of visualization parameters to use for each map. Defaults to [].
        labels (list, optional): The list of labels to show on the map. Defaults to [].
        label_position (str, optional): The position of the label, can be [topleft, topright, bottomleft, bottomright]. Defaults to "topright".

    Raises:
        ValueError: If the length of ee_objects is not equal to rows*cols.
        ValueError: If the length of vis_params is not equal to rows*cols.
        ValueError: If the length of labels is not equal to rows*cols.

    Returns:
        ipywidget: A GridspecLayout widget.
    
Create linked maps of Earth Engine data layers.
Create linked maps of Earth Engine data layers .
def linked_maps(
    rows=2,
    cols=2,
    height="400px",
    ee_objects=[],
    vis_params=[],
    labels=[],
    label_position="topright",
    **kwargs,
):
    grid = widgets.GridspecLayout(rows, cols, grid_gap="0px")
    count = rows * cols
    maps = []
    if len(ee_objects) > 0:
        if len(ee_objects) == 1:
            ee_objects = ee_objects * count
        elif len(ee_objects) < count:
            raise ValueError(f"The length of ee_objects must be equal to {count}.")
    if len(vis_params) > 0:
        if len(vis_params) == 1:
            vis_params = vis_params * count
        elif len(vis_params) < count:
            raise ValueError(f"The length of vis_params must be equal to {count}.")
    if len(labels) > 0:
        if len(labels) == 1:
            labels = labels * count
        elif len(labels) < count:
            raise ValueError(f"The length of labels must be equal to {count}.")
    for i in range(rows):
        for j in range(cols):
            index = i * rows + j
            m = Map(
                height=height,
                lite_mode=True,
                add_google_map=False,
                layout=widgets.Layout(margin="0px", padding="0px"),
                **kwargs,
            )
            if len(ee_objects) > 0:
                m.addLayer(ee_objects[index], vis_params[index], labels[index])
            if len(labels) > 0:
                label = widgets.Label(
                    labels[index], layout=widgets.Layout(padding="0px 5px 0px 5px")
                )
                control = ipyleaflet.WidgetControl(
                    widget=label, position=label_position
                )
                m.add_control(control)
            maps.append(m)
            widgets.jslink((maps[0], "center"), (m, "center"))
            widgets.jslink((maps[0], "zoom"), (m, "zoom"))
            output = widgets.Output()
            with output:
                display(m)
            grid[i, j] = output
    return grid
def linked_maps ( rows = 2 , cols = 2 , height = "400px" , ee_objects = [ ] , vis_params = [ ] , labels = [ ] , label_position = "topright" , ** kwargs , ) : grid = widgets . GridspecLayout ( rows , cols , grid_gap = "0px" ) count = rows * cols maps = [ ] if len ( ee_objects ) > 0 : if len ( ee_objects ) == 1 : ee_objects = ee_objects * count elif len ( ee_objects ) < count : raise ValueError ( f"The length of ee_objects must be equal to {count}." ) if len ( vis_params ) > 0 : if len ( vis_params ) == 1 : vis_params = vis_params * count elif len ( vis_params ) < count : raise ValueError ( f"The length of vis_params must be equal to {count}." ) if len ( labels ) > 0 : if len ( labels ) == 1 : labels = labels * count elif len ( labels ) < count : raise ValueError ( f"The length of labels must be equal to {count}." ) for i in range ( rows ) : for j in range ( cols ) : index = i * rows + j m = Map ( height = height , lite_mode = True , add_google_map = False , layout = widgets . Layout ( margin = "0px" , padding = "0px" ) , ** kwargs , ) if len ( ee_objects ) > 0 : m . addLayer ( ee_objects [ index ] , vis_params [ index ] , labels [ index ] ) if len ( labels ) > 0 : label = widgets . Label ( labels [ index ] , layout = widgets . Layout ( padding = "0px 5px 0px 5px" ) ) control = ipyleaflet . WidgetControl ( widget = label , position = label_position ) m . add_control ( control ) maps . append ( m ) widgets . jslink ( ( maps [ 0 ] , "center" ) , ( m , "center" ) ) widgets . jslink ( ( maps [ 0 ] , "zoom" ) , ( m , "zoom" ) ) output = widgets . Output ( ) with output : display ( m ) grid [ i , j ] = output return grid
Create linked maps of Earth Engine data layers.
Create linked maps of Earth Engine data layers .
"""Create linked maps of Earth Engine data layers.

    Args:
        rows (int, optional): The number of rows of maps to create. Defaults to 2.
        cols (int, optional): The number of columns of maps to create. Defaults to 2.
        height (str, optional): The height of each map in pixels. Defaults to "400px".
        ee_objects (list, optional): The list of Earth Engine objects to use for each map. Defaults to [].
        vis_params (list, optional): The list of visualization parameters to use for each map. Defaults to [].
        labels (list, optional): The list of labels to show on the map. Defaults to [].
        label_position (str, optional): The position of the label, can be [topleft, topright, bottomleft, bottomright]. Defaults to "topright".

    Raises:
        ValueError: If the length of ee_objects is not equal to rows*cols.
        ValueError: If the length of vis_params is not equal to rows*cols.
        ValueError: If the length of labels is not equal to rows*cols.

    Returns:
        ipywidget: A GridspecLayout widget.
    """
A GridspecLayout widget.
A GridspecLayout widget .
ipywidget
If the length of ee_objects is not equal to rows*cols.
If the length of ee_objects is not equal to rows * cols .
ValueError
If the length of vis_params is not equal to rows*cols.
If the length of vis_params is not equal to rows * cols .
ValueError
If the length of labels is not equal to rows*cols.
If the length of labels is not equal to rows * cols .
ValueError
rows
The number of rows of maps to create. Defaults to 2.
The number of rows of maps to create . Defaults to 2 .
2
cols
The number of columns of maps to create. Defaults to 2.
The number of columns of maps to create . Defaults to 2 .
2
height
The height of each map in pixels. Defaults to "400px".
The height of each map in pixels . Defaults to " 400px " .
"400px"
ee_objects
The list of Earth Engine objects to use for each map. Defaults to [].
The list of Earth Engine objects to use for each map . Defaults to [] .
[]
vis_params
The list of visualization parameters to use for each map. Defaults to [].
The list of visualization parameters to use for each map . Defaults to [] .
[]
labels
The list of labels to show on the map. Defaults to [].
The list of labels to show on the map . Defaults to [] .
[]
label_position
The position of the label, can be [topleft, topright, bottomleft, bottomright]. Defaults to "topright".
The position of the label can be [ topleft topright bottomleft bottomright ] . Defaults to " topright " .
"topright"