@@ -70,6 +70,7 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True):
70
70
"""
71
71
super (TimestampedGeoJson , self ).__init__ ()
72
72
self .plugin_name = 'TimestampedGeoJson'
73
+ self .template = self .env .get_template ('timestamped_geo_json.template' )
73
74
if 'read' in dir (data ):
74
75
self .data = data .read ()
75
76
elif type (data ) is dict :
@@ -82,34 +83,11 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True):
82
83
83
84
def render_header (self , nb ):
84
85
"""Generates the header part of the plugin."""
85
- return """
86
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/default.min.css">
87
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
88
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
89
-
90
- <!-- iso8601 -->
91
- <script type="text/javascript" src="https://raw.githubusercontent.com/nezasa/iso8601-js-period/master/iso8601.min.js"></script>
92
-
93
- <!-- leaflet.timedimension.min.js -->
94
- <script type="text/javascript" src="https://raw.githubusercontent.com/socib/Leaflet.TimeDimension/master/dist/leaflet.timedimension.min.js"></script>
95
-
96
- <!-- leaflet.timedimension.control.min.css -->
97
- <link rel="stylesheet" href="http://apps.socib.es/Leaflet.TimeDimension/dist/leaflet.timedimension.control.min.css" />
98
- """ if nb == 0 else ""
86
+ header = self .template .module .__dict__ .get ('header' ,None )
87
+ assert header is not None , "This template must have a 'header' macro."
88
+ return header (nb )
99
89
def render_js (self , nb ):
100
90
"""Generates the Javascript part of the plugin."""
101
- out = """
102
- map.timeDimension = L.timeDimension();
103
- map.timeDimensionControl = L.control.timeDimension({
104
- position: 'bottomleft',
105
- autoPlay: %s,
106
- playerOptions: {transitionTime: %i,loop: %s}
107
- });
108
- map.addControl(map.timeDimensionControl);
109
- """ % (str (self .auto_play ).lower (),self .transition_time ,str (self .loop ).lower ()) if nb == 0 else ""
110
-
111
- out += """
112
- var tsgeojson_%i = L.timeDimension.layer.geoJson(L.geoJson(%s),
113
- {updateTimeDimension: true,addlastPoint: true}).addTo(map);
114
- """ % (nb , self .data )
115
- return out
91
+ js = self .template .module .__dict__ .get ('js' ,None )
92
+ assert js is not None , "This template must have a 'js' macro."
93
+ return js (nb ,self )
0 commit comments