home.html 2.82 KB
Newer Older
1
2
{% extends 'main_website/base.html' %}

Florent Chehab's avatar
Florent Chehab committed
3
4
{% load staticfiles %}

5
{% block content %}
Florent Chehab's avatar
Florent Chehab committed
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
57
58
59
60
61
62
63
64
65
66
67
68
    <div id="mapid" style="height:400px"></div>
    <link rel="stylesheet" href="{% static 'css/leaflet.css' %}"/>
    <script type="text/javascript" src="{% static 'js/leaflet.js' %}"></script>
    <script>

        var Stamen_Watercolor = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.{ext}', {
            attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
            subdomains: 'abcd',
            minZoom: 1,
            maxZoom: 18,
            ext: 'png'
        });

        var Stamen_Label = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-labels/{z}/{x}/{y}.{ext}', {
            attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
            subdomains: 'abcd',
            minZoom: 1,
            maxZoom: 18,
            ext: 'png'
        });

        var OpenStreetMap_Mapnik = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            maxZoom: 19,
            attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
        });

        var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
            attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
        });
        
        var Stamen = L.layerGroup();
        Stamen_Watercolor.addTo(Stamen);
        Stamen_Label.addTo(Stamen);

        var baseLayers = {
            "Stamen Watercolor": Stamen,
            "OpenStreetMap": OpenStreetMap_Mapnik,
            "Satellite": Esri_WorldImagery
        };
    

        var mymap = L.map('mapid', {'layers':Stamen}).setView([45, 1.2], 4);

        L.control.layers(baseLayers).addTo(mymap);
      
        {% for univ in universities %}
            L.marker([{{ univ.localization_lat }}, {{ univ.localization_lon }}]).addTo(mymap)
            .bindPopup("<b>{{ univ.name }}</b>").openPopup();
        {% endfor %}

        var popup = L.popup();
    
        function onMapClick(e) {
            popup
                .setLatLng(e.latlng)
                .setContent("You clicked the map at " + e.latlng.toString())
                .openOn(mymap);
        }
    
        mymap.on('click', onMapClick);
    </script>
    {% for univ in universities %}
        <p>{{ univ.country.name }}</p>
Florent Chehab's avatar
Florent Chehab committed
69
    {% endfor %}
70
71
{% endblock %}