Skip to content

Rationalize Templates #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions folium/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!DOCTYPE html>
<head>
{% block head %}
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
{% endblock head %}

<style>
{% block style %}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
{% endblock style %}
</style>

</head>

<body>
{% block mapdiv %}
<div class="folium-map" id="{{ map_id }}" {{ size }}></div>
{% endblock mapdiv %}

<script>
{% block jscode %}

{{ dvf_js }}
{{ d3 }}
{{ vega }}
{{ jquery }}

{{ vega_parse }}

var base_tile = L.tileLayer('{{ Tiles }}', {
maxZoom: {{ max_zoom }},
minZoom: {{ min_zoom }},
attribution: '{{ attr }}'
});

var baseLayer = {
"Base Layer": base_tile
};

/*
addition of the wms layers
*/

{% for wms in wms_layers %}
{{ wms }}
{% endfor %}

/*
addition of the tile layers
*/
{% for tile in tile_layers %}
{{ tile }}
{% endfor %}

/*
list of layers to be added
*/
var layer_list = {
{% for data_string in data_layers %}
{{ data_string }}
{% endfor %}
};

/*
Bounding box.
*/
var southWest = L.latLng({{ min_lat }}, {{ min_lon }}),
northEast = L.latLng({{ max_lat }}, {{ max_lon }}),
bounds = L.latLngBounds(southWest, northEast);

/*
Creates the map and adds the selected layers
*/
var map = L.map('{{ map_id }}', {
center:[{{ lat }}, {{ lon }}],
zoom: {{ zoom_level }},
maxBounds: bounds,
layers: [base_tile]
});

L.control.layers(baseLayer, layer_list).addTo(map);

//cluster group
var clusteredmarkers = L.markerClusterGroup();
//section for adding clustered markers
{% for icon, mark, popup, add_mark in cluster_markers %}
{{ icon }}
{{ mark }}
{{ popup }}
{{ add_mark }}
{% endfor %}
//add the clustered markers to the group anyway
map.addLayer(clusteredmarkers);

{% for icon, mark, popup, add_mark in custom_markers %}
{{ icon }}
{{ mark }}
{{ popup }}
{{ add_mark }}
{% endfor %}

{% for mark, popup, add_mark in markers %}
{{ mark }}
{{ popup }}
{{ add_mark }}
{% endfor %}

{% for line, popup, add_line in lines %}
{{ line }}
{{ popup }}
{{ add_line }}
{% endfor %}

{% for multiline, add_multiline in multilines %}
{{ multiline }}
{{ add_multiline }}
{% endfor %}

{{ lat_lng_pop }}

{{ click_pop }}

{% if fit_bounds %}{{ fit_bounds }}{% endif %}

{% endblock jscode %}

</script>
</body>
160 changes: 12 additions & 148 deletions folium/templates/fol_template.html
Original file line number Diff line number Diff line change
@@ -1,156 +1,20 @@
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">

<link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
<script src="https://rawi.8713187.xyz/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>

{% extends "base.html" %}
{% block head %}
{{ super() }}

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

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

{{ dvf_js }}
{{ d3 }}
{{ vega }}
{{ jquery }}

<style>

html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}

#map {
position:absolute;
top:0;
bottom:0;
right:0;
left:0;
}

</style>
</head>

<body>

<div class="folium-map" id="{{ map_id }}" {{ size }}></div>

<script>

{{ vega_parse }}

var base_tile = L.tileLayer('{{ Tiles }}', {
maxZoom: {{ max_zoom }},
minZoom: {{ min_zoom }},
attribution: '{{ attr }}'
});

var baseLayer = {
"Base Layer": base_tile
};

/*
addition of the wms layers
*/

{% for wms in wms_layers %}
{{ wms }}
{% endfor %}

/*
addition of the tile layers
*/
{% for tile in tile_layers %}
{{ tile }}
{% endfor %}

/*
list of layers to be added
*/
var layer_list = {
{% for data_string in data_layers %}
{{ data_string }}
{% endfor %}
};

/*
Bounding box.
*/
var southWest = L.latLng({{ min_lat }}, {{ min_lon }}),
northEast = L.latLng({{ max_lat }}, {{ max_lon }}),
bounds = L.latLngBounds(southWest, northEast);

/*
Creates the map and adds the selected layers
*/
var map = L.map('{{ map_id }}', {
center:[{{ lat }}, {{ lon }}],
zoom: {{ zoom_level }},
maxBounds: bounds,
layers: [base_tile]
});

L.control.layers(baseLayer, layer_list).addTo(map);

//cluster group
var clusteredmarkers = L.markerClusterGroup();
//section for adding clustered markers
{% for icon, mark, popup, add_mark in cluster_markers %}
{{ icon }}
{{ mark }}
{{ popup }}
{{ add_mark }}
{% endfor %}
//add the clustered markers to the group anyway
map.addLayer(clusteredmarkers);

{% for icon, mark, popup, add_mark in custom_markers %}
{{ icon }}
{{ mark }}
{{ popup }}
{{ add_mark }}
{% endfor %}

{% for mark, popup, add_mark in markers %}
{{ mark }}
{{ popup }}
{{ add_mark }}
{% endfor %}

{% for line, popup, add_line in lines %}
{{ line }}
{{ popup }}
{{ add_line }}
{% endfor %}

{% for multiline, add_multiline in multilines %}
{{ multiline }}
{{ add_multiline }}
{% endfor %}

{{ lat_lng_pop }}

{{ click_pop }}

{% if fit_bounds %}{{ fit_bounds }}{% endif %}

</script>

</body>
{% endblock %}
36 changes: 15 additions & 21 deletions folium/templates/geojson_template.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
{% extends "base.html" %}
{% block head %}
{{ super() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>

{{ dvf_js }}
{{ topojson }}
{{ vega }}
{{ jquery }}

<style>

html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
{% endblock head %}

{% block style %}
{{ super() }}
.legend {
padding: 0px 0px;
font: 10px sans-serif;
Expand All @@ -33,14 +20,20 @@
display: none;
}

</style>
</head>
{% endblock style %}

<body>

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

<script>
{% block jscode %}

{{ dvf_js }}
{{ d3 }}
{{ vega }}
{{ jquery }}


queue()
{%- for load_path in json_paths %}
Expand Down Expand Up @@ -121,6 +114,7 @@
{{ fit_bounds }}

};
{% endblock jscode %}

</script>
</body>