geemap/geemap.py
def to_html(
        self,
        outfile=None,
        title="My Map",
        width="100%",
        height="880px",
        add_layer_control=True,
        **kwargs,
    ):
        """Saves the map as an HTML file.

        Args:
            outfile (str, optional): The output file path to the HTML file.
            title (str, optional): The title of the HTML file. Defaults to 'My Map'.
            width (str, optional): The width of the map in pixels or percentage. Defaults to '100%'.
            height (str, optional): The height of the map in pixels. Defaults to '880px'.
            add_layer_control (bool, optional): Whether to add the LayersControl. Defaults to True.

        """
        try:

            save = True
            if outfile is not None:
                if not outfile.endswith(".html"):
                    raise ValueError("The output file extension must be html.")
                outfile = os.path.abspath(outfile)
                out_dir = os.path.dirname(outfile)
                if not os.path.exists(out_dir):
                    os.makedirs(out_dir)
            else:
                outfile = os.path.abspath(random_string() + ".html")
                save = False

            if add_layer_control and self.layer_control is None:
                layer_control = ipyleaflet.LayersControl(position="topright")
                self.layer_control = layer_control
                self.add_control(layer_control)

            before_width = self.layout.width
            before_height = self.layout.height

            if not isinstance(width, str):
                print("width must be a string.")
                return
            elif width.endswith("px") or width.endswith("%"):
                pass
            else:
                print("width must end with px or %")
                return

            if not isinstance(height, str):
                print("height must be a string.")
                return
            elif not height.endswith("px"):
                print("height must end with px")
                return

            self.layout.width = width
            self.layout.height = height

            self.save(outfile, title=title, **kwargs)

            self.layout.width = before_width
            self.layout.height = before_height

            if not save:
                out_html = ""
                with open(outfile) as f:
                    lines = f.readlines()
                    out_html = "".join(lines)
                os.remove(outfile)
                return out_html

        except Exception as e:
            raise Exception(e)
Saves the map as an HTML file.

        Args:
            outfile (str, optional): The output file path to the HTML file.
            title (str, optional): The title of the HTML file. Defaults to 'My Map'.
            width (str, optional): The width of the map in pixels or percentage. Defaults to '100%'.
            height (str, optional): The height of the map in pixels. Defaults to '880px'.
            add_layer_control (bool, optional): Whether to add the LayersControl. Defaults to True.

        
Saves the map as an HTML file.
Saves the map as an HTML file .
def to_html(
        self,
        outfile=None,
        title="My Map",
        width="100%",
        height="880px",
        add_layer_control=True,
        **kwargs,
    ):
        try:
            save = True
            if outfile is not None:
                if not outfile.endswith(".html"):
                    raise ValueError("The output file extension must be html.")
                outfile = os.path.abspath(outfile)
                out_dir = os.path.dirname(outfile)
                if not os.path.exists(out_dir):
                    os.makedirs(out_dir)
            else:
                outfile = os.path.abspath(random_string() + ".html")
                save = False
            if add_layer_control and self.layer_control is None:
                layer_control = ipyleaflet.LayersControl(position="topright")
                self.layer_control = layer_control
                self.add_control(layer_control)
            before_width = self.layout.width
            before_height = self.layout.height
            if not isinstance(width, str):
                print("width must be a string.")
                return
            elif width.endswith("px") or width.endswith("%"):
                pass
            else:
                print("width must end with px or %")
                return
            if not isinstance(height, str):
                print("height must be a string.")
                return
            elif not height.endswith("px"):
                print("height must end with px")
                return
            self.layout.width = width
            self.layout.height = height
            self.save(outfile, title=title, **kwargs)
            self.layout.width = before_width
            self.layout.height = before_height
            if not save:
                out_html = ""
                with open(outfile) as f:
                    lines = f.readlines()
                    out_html = "".join(lines)
                os.remove(outfile)
                return out_html
        except Exception as e:
            raise Exception(e)
def to_html ( self , outfile = None , title = "My Map" , width = "100%" , height = "880px" , add_layer_control = True , ** kwargs , ) : try : save = True if outfile is not None : if not outfile . endswith ( ".html" ) : raise ValueError ( "The output file extension must be html." ) outfile = os . path . abspath ( outfile ) out_dir = os . path . dirname ( outfile ) if not os . path . exists ( out_dir ) : os . makedirs ( out_dir ) else : outfile = os . path . abspath ( random_string ( ) + ".html" ) save = False if add_layer_control and self . layer_control is None : layer_control = ipyleaflet . LayersControl ( position = "topright" ) self . layer_control = layer_control self . add_control ( layer_control ) before_width = self . layout . width before_height = self . layout . height if not isinstance ( width , str ) : print ( "width must be a string." ) return elif width . endswith ( "px" ) or width . endswith ( "%" ) : pass else : print ( "width must end with px or %" ) return if not isinstance ( height , str ) : print ( "height must be a string." ) return elif not height . endswith ( "px" ) : print ( "height must end with px" ) return self . layout . width = width self . layout . height = height self . save ( outfile , title = title , ** kwargs ) self . layout . width = before_width self . layout . height = before_height if not save : out_html = "" with open ( outfile ) as f : lines = f . readlines ( ) out_html = "" . join ( lines ) os . remove ( outfile ) return out_html except Exception as e : raise Exception ( e )
Saves the map as an HTML file.
Saves the map as an HTML file .
"""Saves the map as an HTML file.

        Args:
            outfile (str, optional): The output file path to the HTML file.
            title (str, optional): The title of the HTML file. Defaults to 'My Map'.
            width (str, optional): The width of the map in pixels or percentage. Defaults to '100%'.
            height (str, optional): The height of the map in pixels. Defaults to '880px'.
            add_layer_control (bool, optional): Whether to add the LayersControl. Defaults to True.

        """
self
outfile
The output file path to the HTML file.
The output file path to the HTML file .
title
The title of the HTML file. Defaults to 'My Map'.
The title of the HTML file . Defaults to ' My Map ' .
'My Map'
width
The width of the map in pixels or percentage.
The width of the map in pixels or percentage .
'100%'
height
The height of the map in pixels. Defaults to '880px'.
The height of the map in pixels . Defaults to ' 880px ' .
'880px'
add_layer_control
Whether to add the LayersControl. Defaults to True.
Whether to add the LayersControl . Defaults to True .
True