Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
402c8fb9
Commit
402c8fb9
authored
Apr 01, 2018
by
Florent Chehab
Browse files
map preview added
parent
e26d998e
Changes
6
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
402c8fb9
...
...
@@ -4,4 +4,5 @@ myvenv
db.sqlite3
/static
.DS_Store
/media/*
\ No newline at end of file
/media/*
node_modules
package-lock.json
0 → 100644
View file @
402c8fb9
{
"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=="
}
}
}
rex/static/css/leaflet.css
0 → 120000
View file @
402c8fb9
../../../
node_modules
/
leaflet
/
dist
/
leaflet
.css
\ No newline at end of file
rex/static/js/leaflet.js
0 → 120000
View file @
402c8fb9
..
/
..
/
..
/
node_modules
/
leaflet
/
dist
/
leaflet
.
js
\ No newline at end of file
rex/templates/rex/home.html
View file @
402c8fb9
{% 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> — Map data © <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> — Map data © <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
:
'
© <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 © Esri — 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
rex/views.py
View file @
402c8fb9
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment