Commit 402c8fb9 authored by Florent Chehab's avatar Florent Chehab

map preview added

parent e26d998e
......@@ -5,3 +5,4 @@ db.sqlite3
/static
.DS_Store
/media/*
node_modules
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"leaflet": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.3.1.tgz",
"integrity": "sha512-adQOIzh+bfdridLM1xIgJ9VnJbAUY3wqs/ueF+ITla+PLQ1z47USdBKUf+iD9FuUA8RtlT6j6hZBfZoA6mW+XQ=="
},
"leaflet.markercluster": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/leaflet.markercluster/-/leaflet.markercluster-1.3.0.tgz",
"integrity": "sha512-bHBaI8kTaLrZxI/ZP7pnNaS8WCKKz98BU1//B5OH9b/kTk6IriduvDtMFGlGBYYr/ymuXCB9lO7HsGBr5dSw5w=="
}
}
}
../../../node_modules/leaflet/dist/leaflet.css
\ No newline at end of file
../../../node_modules/leaflet/dist/leaflet.js
\ No newline at end of file
{% extends 'main_website/base.html' %}
{% load staticfiles %}
{% block content %}
{% for post in posts %}
<div>
<p>publié: {{ post.published_date }}</p>
<h1><a href="">{{ post.title }}</a></h1>
<p>{{ post.text|linebreaksbr }}</p>
</div>
<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>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.shortcuts import render
from django.utils import timezone
from .models.university import University
from rex.models.university import University
def home(request):
pass
# from .models import Post
# def post_list(request):
# posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
# return render(request, 'rex/post_list.html', {'posts': posts})
\ No newline at end of file
universities = University.objects.all()
return render(request, 'rex/home.html', {'universities': universities})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment