Skip to content

Commit 3b6f9cb

Browse files
committed
Rationalize templates
1 parent a7fd9b9 commit 3b6f9cb

File tree

3 files changed

+165
-169
lines changed

3 files changed

+165
-169
lines changed

folium/templates/base.html

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<!DOCTYPE html>
2+
<head>
3+
{% block head %}
4+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
6+
7+
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
8+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
10+
{% endblock head %}
11+
12+
<style>
13+
{% block style %}
14+
html, body {
15+
width: 100%;
16+
height: 100%;
17+
margin: 0;
18+
padding: 0;
19+
}
20+
{% endblock style %}
21+
</style>
22+
23+
</head>
24+
25+
<body>
26+
{% block mapdiv %}
27+
<div class="folium-map" id="{{ map_id }}" {{ size }}></div>
28+
{% endblock mapdiv %}
29+
30+
<script>
31+
{% block jscode %}
32+
33+
{{ dvf_js }}
34+
{{ d3 }}
35+
{{ vega }}
36+
{{ jquery }}
37+
38+
{{ vega_parse }}
39+
40+
var base_tile = L.tileLayer('{{ Tiles }}', {
41+
maxZoom: {{ max_zoom }},
42+
minZoom: {{ min_zoom }},
43+
attribution: '{{ attr }}'
44+
});
45+
46+
var baseLayer = {
47+
"Base Layer": base_tile
48+
};
49+
50+
/*
51+
addition of the wms layers
52+
*/
53+
54+
{% for wms in wms_layers %}
55+
{{ wms }}
56+
{% endfor %}
57+
58+
/*
59+
addition of the tile layers
60+
*/
61+
{% for tile in tile_layers %}
62+
{{ tile }}
63+
{% endfor %}
64+
65+
/*
66+
list of layers to be added
67+
*/
68+
var layer_list = {
69+
{% for data_string in data_layers %}
70+
{{ data_string }}
71+
{% endfor %}
72+
};
73+
74+
/*
75+
Bounding box.
76+
*/
77+
var southWest = L.latLng({{ min_lat }}, {{ min_lon }}),
78+
northEast = L.latLng({{ max_lat }}, {{ max_lon }}),
79+
bounds = L.latLngBounds(southWest, northEast);
80+
81+
/*
82+
Creates the map and adds the selected layers
83+
*/
84+
var map = L.map('{{ map_id }}', {
85+
center:[{{ lat }}, {{ lon }}],
86+
zoom: {{ zoom_level }},
87+
maxBounds: bounds,
88+
layers: [base_tile]
89+
});
90+
91+
L.control.layers(baseLayer, layer_list).addTo(map);
92+
93+
//cluster group
94+
var clusteredmarkers = L.markerClusterGroup();
95+
//section for adding clustered markers
96+
{% for icon, mark, popup, add_mark in cluster_markers %}
97+
{{ icon }}
98+
{{ mark }}
99+
{{ popup }}
100+
{{ add_mark }}
101+
{% endfor %}
102+
//add the clustered markers to the group anyway
103+
map.addLayer(clusteredmarkers);
104+
105+
{% for icon, mark, popup, add_mark in custom_markers %}
106+
{{ icon }}
107+
{{ mark }}
108+
{{ popup }}
109+
{{ add_mark }}
110+
{% endfor %}
111+
112+
{% for mark, popup, add_mark in markers %}
113+
{{ mark }}
114+
{{ popup }}
115+
{{ add_mark }}
116+
{% endfor %}
117+
118+
{% for line, popup, add_line in lines %}
119+
{{ line }}
120+
{{ popup }}
121+
{{ add_line }}
122+
{% endfor %}
123+
124+
{% for multiline, add_multiline in multilines %}
125+
{{ multiline }}
126+
{{ add_multiline }}
127+
{% endfor %}
128+
129+
{{ lat_lng_pop }}
130+
131+
{{ click_pop }}
132+
133+
{% if fit_bounds %}{{ fit_bounds }}{% endif %}
134+
135+
{% endblock jscode %}
136+
137+
</script>
138+
</body>

folium/templates/fol_template.html

Lines changed: 12 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,20 @@
1-
<!DOCTYPE html>
2-
<head>
3-
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5-
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
6-
7-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
8-
9-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
10-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
11-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
12-
13-
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
14-
15-
<link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
16-
<script src="https://rawi.8713187.xyz/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>
17-
1+
{% extends "base.html" %}
2+
{% block head %}
3+
{{ super() }}
184

5+
<!-- Marker Clusters -->
196
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css">
207
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css">
218
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster-src.js"></script>
229
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js"></script>
2310

11+
<!-- Awesome markers, needs cleanup -->
12+
<link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
13+
<script src="https://rawi.8713187.xyz/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>
14+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
15+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
16+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
17+
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
2418
<link rel="stylesheet" href="https://birdage.github.io/Leaflet.awesome-markers/dist/leaflet.awesome.rotate.css">
2519

26-
{{ dvf_js }}
27-
{{ d3 }}
28-
{{ vega }}
29-
{{ jquery }}
30-
31-
<style>
32-
33-
html, body {
34-
width: 100%;
35-
height: 100%;
36-
margin: 0;
37-
padding: 0;
38-
}
39-
40-
#map {
41-
position:absolute;
42-
top:0;
43-
bottom:0;
44-
right:0;
45-
left:0;
46-
}
47-
48-
</style>
49-
</head>
50-
51-
<body>
52-
53-
<div class="folium-map" id="{{ map_id }}" {{ size }}></div>
54-
55-
<script>
56-
57-
{{ vega_parse }}
58-
59-
var base_tile = L.tileLayer('{{ Tiles }}', {
60-
maxZoom: {{ max_zoom }},
61-
minZoom: {{ min_zoom }},
62-
attribution: '{{ attr }}'
63-
});
64-
65-
var baseLayer = {
66-
"Base Layer": base_tile
67-
};
68-
69-
/*
70-
addition of the wms layers
71-
*/
72-
73-
{% for wms in wms_layers %}
74-
{{ wms }}
75-
{% endfor %}
76-
77-
/*
78-
addition of the tile layers
79-
*/
80-
{% for tile in tile_layers %}
81-
{{ tile }}
82-
{% endfor %}
83-
84-
/*
85-
list of layers to be added
86-
*/
87-
var layer_list = {
88-
{% for data_string in data_layers %}
89-
{{ data_string }}
90-
{% endfor %}
91-
};
92-
93-
/*
94-
Bounding box.
95-
*/
96-
var southWest = L.latLng({{ min_lat }}, {{ min_lon }}),
97-
northEast = L.latLng({{ max_lat }}, {{ max_lon }}),
98-
bounds = L.latLngBounds(southWest, northEast);
99-
100-
/*
101-
Creates the map and adds the selected layers
102-
*/
103-
var map = L.map('{{ map_id }}', {
104-
center:[{{ lat }}, {{ lon }}],
105-
zoom: {{ zoom_level }},
106-
maxBounds: bounds,
107-
layers: [base_tile]
108-
});
109-
110-
L.control.layers(baseLayer, layer_list).addTo(map);
111-
112-
//cluster group
113-
var clusteredmarkers = L.markerClusterGroup();
114-
//section for adding clustered markers
115-
{% for icon, mark, popup, add_mark in cluster_markers %}
116-
{{ icon }}
117-
{{ mark }}
118-
{{ popup }}
119-
{{ add_mark }}
120-
{% endfor %}
121-
//add the clustered markers to the group anyway
122-
map.addLayer(clusteredmarkers);
123-
124-
{% for icon, mark, popup, add_mark in custom_markers %}
125-
{{ icon }}
126-
{{ mark }}
127-
{{ popup }}
128-
{{ add_mark }}
129-
{% endfor %}
130-
131-
{% for mark, popup, add_mark in markers %}
132-
{{ mark }}
133-
{{ popup }}
134-
{{ add_mark }}
135-
{% endfor %}
136-
137-
{% for line, popup, add_line in lines %}
138-
{{ line }}
139-
{{ popup }}
140-
{{ add_line }}
141-
{% endfor %}
142-
143-
{% for multiline, add_multiline in multilines %}
144-
{{ multiline }}
145-
{{ add_multiline }}
146-
{% endfor %}
147-
148-
{{ lat_lng_pop }}
149-
150-
{{ click_pop }}
151-
152-
{% if fit_bounds %}{{ fit_bounds }}{% endif %}
153-
154-
</script>
155-
156-
</body>
20+
{% endblock %}

folium/templates/geojson_template.html

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
<!DOCTYPE html>
2-
<head>
3-
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5-
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
6-
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
1+
{% extends "base.html" %}
2+
{% block head %}
3+
{{ super() }}
74
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>
85

9-
{{ dvf_js }}
10-
{{ topojson }}
11-
{{ vega }}
12-
{{ jquery }}
13-
14-
<style>
15-
16-
html, body {
17-
width: 100%;
18-
height: 100%;
19-
margin: 0;
20-
padding: 0;
21-
}
6+
{% endblock head %}
227

8+
{% block style %}
9+
{{ super() }}
2310
.legend {
2411
padding: 0px 0px;
2512
font: 10px sans-serif;
@@ -33,14 +20,20 @@
3320
display: none;
3421
}
3522

36-
</style>
37-
</head>
23+
{% endblock style %}
3824

3925
<body>
4026

4127
<div id="map" {{ size }}></div>
4228

4329
<script>
30+
{% block jscode %}
31+
32+
{{ dvf_js }}
33+
{{ d3 }}
34+
{{ vega }}
35+
{{ jquery }}
36+
4437

4538
queue()
4639
{%- for load_path in json_paths %}
@@ -121,6 +114,7 @@
121114
{{ fit_bounds }}
122115

123116
};
117+
{% endblock jscode %}
124118

125119
</script>
126120
</body>

0 commit comments

Comments
 (0)