add level control to map editor
This commit is contained in:
parent
a546d27efa
commit
bc29193c7b
3 changed files with 32 additions and 1 deletions
|
@ -12,3 +12,12 @@
|
||||||
margin: 2px 0 0;
|
margin: 2px 0 0;
|
||||||
top:2px;
|
top:2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.leaflet-levels a {
|
||||||
|
font-size:16px;
|
||||||
|
color:#333333;
|
||||||
|
}
|
||||||
|
.leaflet-levels a.current {
|
||||||
|
font-weight:bold;
|
||||||
|
color:#000000;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,27 @@ L.control.layers([], {
|
||||||
"{{ source.name }}": L.imageOverlay('{% url 'map.source' filename=source.filename %}', {{ source.jsbounds }}),{% endfor %}
|
"{{ source.name }}": L.imageOverlay('{% url 'map.source' filename=source.filename %}', {{ source.jsbounds }}),{% endfor %}
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
L.LevelControl = L.Control.extend({
|
||||||
|
|
||||||
|
options: {
|
||||||
|
position: 'bottomright'
|
||||||
|
},
|
||||||
|
|
||||||
|
onAdd: function (map) {
|
||||||
|
var container = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-levels'), link;
|
||||||
|
{% for level in map.levels reversed %}
|
||||||
|
link = L.DomUtil.create('a', '{% if current_level == level %}current{% endif %}', container);
|
||||||
|
link.href = '{% url "control.editor" level=level %}';
|
||||||
|
link.innerHTML = '{{ level }}';
|
||||||
|
{% endfor %}
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
map.addControl(new L.LevelControl());
|
||||||
|
|
||||||
|
|
||||||
L.control.scale({imperial: false}).addTo(map);
|
L.control.scale({imperial: false}).addTo(map);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -17,5 +17,6 @@ def editor(request, level=None):
|
||||||
if level not in mapmanager.levels:
|
if level not in mapmanager.levels:
|
||||||
raise Http404('Level does not exist')
|
raise Http404('Level does not exist')
|
||||||
return render(request, 'control/editor.html', {
|
return render(request, 'control/editor.html', {
|
||||||
'map': mapmanager
|
'map': mapmanager,
|
||||||
|
'current_level': level,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue