summaryrefslogtreecommitdiff
path: root/design/templates/archives/map_data.html
blob: 120704c4bd8658e9916935dd7f2f588d300162c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{% load typogrify_tags %}
{% load truncateletters  %}

var map = L.map('map-inner-canvas')

// center on a country
function focusCountry(latitude, longitude, zoom) {
  map.panTo(new L.LatLng(latitude, longitude));
  map.setZoom(zoom);
};

{% for route in route_list %}
var {{route.template_var_name}} = L.polygon([
{% for point in route.geometry.coords%}
    [{{point.1}}, {{point.0}}]{% if forloop.last%}{%else%},{%endif%}
{% endfor %}
  ]);
  {% endfor %}
  
function showRoute(route, zoom, latitude, longitude) {
    map.panTo(new L.LatLng(latitude, longitude));
    map.setZoom(zoom);
    eval(route).addTo(map);  
    return false;
};
    //check for a permalink
    //find a centerpoint
    var pts = new Array();
    {%for c in country_list%}pts[{{forloop.counter0}}] = ["#{{c.slug}}", {{c.lat}},{{c.lon}},{{c.zoom_level}}];
    {% endfor %}
    {%for c in region_list%}pts[pts.length] = ["#{{c.slug}}", {{c.lat}},{{c.lon}},{{c.zoom_level}}];
    {% endfor %}
if (window.location.hash) {
    for (var i=0; i < pts.length; i++) {
        if (window.location.hash == pts[i][0]) {
            var centerCoord = new L.LatLng(pts[i][1],pts[i][2]);
            var zoom = pts[i][3];
            break;
        } else {
            var centerCoord = new L.LatLng(19.311143,2.460938);
            var zoom = 2;
        }
    }
} else {
    centerCoord = new L.LatLng(19.311143,2.460938);
    zoom = 2;
}
//Set center
map.setView(centerCoord, zoom);
L.tileLayer.provider('Esri.WorldTopoMap', {maxZoom: 18,attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Tiles &copy; Esri and the GIS User Community'}).addTo(map);

//loop through and set up markers/info windows
{% for entry in object_list %}
L.marker([{{entry.latitude}}, {{entry.longitude}}]).bindPopup('<div class="infowin"><h4>{{entry.title}}<\/h4><span class="date blok">{{entry.pub_date|date:"F j, Y"}} ({% if entry.location.state.country.name == "United States" %}{{entry.location.name|smartypants|safe}}, {{entry.location.state.name}}){%else%}{{entry.location.name|smartypants|safe}}, {{entry.location.state.country.name}}){%endif%}<\/span><p><img src="{{entry.get_thumbnail_url}}" height="100" alt="{{ entry.title }}"  style="float: left; border: #000 10px solid; margin-right: 8px; margin-bottom: 4px; height: 100px;" \/>{{entry.dek|escapejs}} <a href="{{entry.get_absolute_url}}">Read it &raquo;<\/a><\/p><\/div>').addTo(map);
{% endfor %}