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
1af1c62d
Commit
1af1c62d
authored
Apr 01, 2018
by
Florent Chehab
Browse files
Marker clustering added
parent
402c8fb9
Changes
5
Hide whitespace changes
Inline
Side-by-side
rex/static/css/MarkerCluster.Default.css
0 → 120000
View file @
1af1c62d
../../../
node_modules
/
leaflet
.markercluster
/
dist
/
MarkerCluster
.Default.css
\ No newline at end of file
rex/static/css/MarkerCluster.css
0 → 120000
View file @
1af1c62d
../../../
node_modules
/
leaflet
.markercluster
/
dist
/
MarkerCluster
.css
\ No newline at end of file
rex/static/css/images
0 → 120000
View file @
1af1c62d
../../../node_modules/leaflet/dist/images
\ No newline at end of file
rex/static/js/leaflet.markercluster.js
0 → 120000
View file @
1af1c62d
..
/
..
/
..
/
node_modules
/
leaflet
.
markercluster
/
dist
/
leaflet
.
markercluster
.
js
\ No newline at end of file
rex/templates/rex/home.html
View file @
1af1c62d
...
...
@@ -4,8 +4,14 @@
{% block content %}
<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>
<link
rel=
"stylesheet"
href=
"{% static 'css/MarkerCluster.css' %}"
/>
<link
rel=
"stylesheet"
href=
"{% static 'css/MarkerCluster.Default.css' %}"
/>
<script
type=
"text/javascript"
src=
"{% static 'js/leaflet.markercluster.js' %}"
></script>
<script>
var
Stamen_Watercolor
=
L
.
tileLayer
(
'
https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.{ext}
'
,
{
...
...
@@ -43,16 +49,23 @@
"
Satellite
"
:
Esri_WorldImagery
};
// End of handling of layers, now let's handle markers.
var
mymap
=
L
.
map
(
'
mapid
'
,
{
'
layers
'
:
Stamen
}).
setView
([
45
,
1.2
],
4
);
var
universities_markers
=
L
.
markerClusterGroup
(
);
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
()
;
L
.
marker
([{{
univ
.
localization_lat
}},
{{
univ
.
localization_lon
}}]).
addTo
(
universities_markers
)
.
bindPopup
(
"
<b>{{ univ.name }}</b>
"
);
{
%
endfor
%
}
// Creation of map
var
mymap
=
L
.
map
(
'
mapid
'
,
{
'
layers
'
:[
Stamen
,
universities_markers
]}).
setView
([
45
,
1.2
],
4
);
L
.
control
.
layers
(
baseLayers
).
addTo
(
mymap
);
// Extra feature
var
popup
=
L
.
popup
();
function
onMapClick
(
e
)
{
...
...
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