File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66import time
77import warnings
8+ import webbrowser
89
910from branca .element import Element , Figure , MacroElement
1011
@@ -375,6 +376,21 @@ def render(self, **kwargs):
375376
376377 super (Map , self ).render (** kwargs )
377378
379+ def show_in_browser (self ):
380+ """Display the Map in the default web browser."""
381+ with temp_html_filepath (self .get_root ().render ()) as fname :
382+ webbrowser .open (fname )
383+ print (
384+ 'Your map should have been opened in your browser automatically.'
385+ '\n Press ctrl+c to return.'
386+ )
387+ # Block until stopped by user, afterwards remove the temporary file
388+ try :
389+ while True :
390+ time .sleep (100 )
391+ except KeyboardInterrupt :
392+ pass
393+
378394 def fit_bounds (self , bounds , padding_top_left = None ,
379395 padding_bottom_right = None , padding = None , max_zoom = None ):
380396 """Fit the map to contain a bounding box with the
You can’t perform that action at this time.
0 commit comments