@@ -585,18 +585,22 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
585
585
self .template_vars .setdefault ('geo_styles' , []).append (style )
586
586
self .template_vars .setdefault ('gjson_layers' , []).append (layer )
587
587
588
- def _build_map (self ):
588
+ def _build_map (self , html_templ = None ):
589
589
'''Build HTML/JS/CSS from Templates given current map type'''
590
- map_types = {'base' : 'fol_template.html' ,
591
- 'geojson' : 'geojson_template.html' }
590
+ if html_templ is None :
591
+ map_types = {'base' : 'fol_template.html' ,
592
+ 'geojson' : 'geojson_template.html' }
592
593
593
- #Check current map type
594
- type_temp = map_types [self .map_type ]
594
+ #Check current map type
595
+ type_temp = map_types [self .map_type ]
596
+
597
+ html_templ = self .env .get_template (type_temp )
598
+ else :
599
+ html_templ = self .env .from_string (html_templ )
595
600
596
- html_templ = self .env .get_template (type_temp )
597
601
self .HTML = html_templ .render (self .template_vars )
598
602
599
- def create_map (self , path = 'map.html' , plugin_data_out = True ):
603
+ def create_map (self , path = 'map.html' , plugin_data_out = True , template = None ):
600
604
'''Write Map output to HTML and data output to JSON if available
601
605
602
606
Parameters:
@@ -606,10 +610,12 @@ def create_map(self, path='map.html', plugin_data_out=True):
606
610
plugin_data_out: boolean, default True
607
611
If using plugins such as awesome markers, write all plugin
608
612
data such as JS/CSS/images to path
613
+ template: string, default None
614
+ Custom template to render
609
615
610
616
'''
611
617
612
- self ._build_map ()
618
+ self ._build_map (template )
613
619
614
620
with codecs .open (path , 'w' , 'utf-8' ) as f :
615
621
f .write (self .HTML )
0 commit comments