Commit f53dd92e authored by Alexander Basov's avatar Alexander Basov

fixed map layers list

parent a4571148
...@@ -32,9 +32,16 @@ ...@@ -32,9 +32,16 @@
<ul class="nav nav-pills "> <ul class="nav nav-pills ">
<li style="margin-left: 5px" class="active dropdown form-horizontal pull-right"> <li style="margin-left: 5px" class="active dropdown form-horizontal pull-right">
<a id="get-providers" href="#"><spring:message code="mapproviders.list"/></a> <a class="dropdown-toggle" data-toggle="dropdown" href="#"><spring:message code="mapproviders.list"/></a>
<ul id="enabled-providers" class="dropdown-menu"></ul> <ul class="dropdown-menu">
<li>
<label><input class="map-provider" name="provider" style='margin-right: 10px;margin-left: 5px'
type='radio'>MapQuest</label>
<label><input name="provider" class="map-provider" style='margin-right: 10px;margin-left: 5px'
type='radio'>Openstreetmap</label>
</li>
</ul>
</li> </li>
...@@ -110,40 +117,33 @@ ...@@ -110,40 +117,33 @@
Openstreetmap: L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { Openstreetmap: L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}), }),
OpenMapSurfer_Grayscale: L.tileLayer('http://openmapsurfer.uni-hd.de/tiles/roadsg/x={x}&y={y}&z={z}', { /* OpenMapSurfer_Grayscale: L.tileLayer('http://openmapsurfer.uni-hd.de/tiles/roadsg/x={x}&y={y}&z={z}', {
maxZoom: 19, maxZoom: 19,
attribution: 'Imagery from <a target="_blank" href="http://giscience.uni-hd.de/">GIScience Research Group, University of Heidelberg</a>, Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' attribution: 'Imagery from <a target="_blank" href="http://giscience.uni-hd.de/">GIScience Research Group, University of Heidelberg</a>, Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}), }),*/
MapQuest: L.tileLayer('https://otile{s}-s.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { MapQuest: L.tileLayer('https://otile{s}-s.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
attribution: "MapQuest", attribution: "MapQuest",
styleId: 22677, styleId: 22677,
subdomains: ['1', '2', '3', '4'], subdomains: ['1', '2', '3', '4'],
opacity: 0.6 opacity: 0.6
}),
Stamen_TonerLines: L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lines/{z}/{x}/{y}.png', {
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',
opacity: 0.3,
minZoom: 0,
maxZoom: 20,
ext: 'png'
}),
Acetate_labels: L.tileLayer('http://a{s}.acetate.geoiq.com/tiles/acetate-labels/{z}/{x}/{y}.png', {
attribution: '&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
subdomains: '0123',
opacity: 0.6,
minZoom: 2,
maxZoom: 18
}) })
/*Stamen_TonerLines: L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lines/{z}/{x}/{y}.png', {
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',
opacity: 0.3,
minZoom: 0,
maxZoom: 20,
ext: 'png'
}),
Acetate_labels: L.tileLayer('http://a{s}.acetate.geoiq.com/tiles/acetate-labels/{z}/{x}/{y}.png', {
attribution: '&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
subdomains: '0123',
opacity: 0.6,
minZoom: 2,
maxZoom: 18
})*/
}; };
for(var key in mapProviders){
var li = "<li><label class='map-provider'><input style='margin-right: 10px;margin-left: 5px' type='checkbox'>" + key + "</label></li>";
$('#enabled-providers').append(li);
}
$('#get-providers').on('click', function(){
$('#enabled-providers').toggle();
});
var cookieUtils = { var cookieUtils = {
getCookie: function (name) { getCookie: function (name) {
...@@ -186,44 +186,31 @@ ...@@ -186,44 +186,31 @@
}) })
} }
}; };
// cookieUtils.deleteCookie('mapProviders'); if (cookieUtils.getCookie('mapProviders') && cookieUtils.getCookie('mapProviders') != '') {
if(cookieUtils.getCookie('mapProviders') && cookieUtils.getCookie('mapProviders')!=''){ mapProviders[cookieUtils.getCookie('mapProviders')].addTo(map);
cookieUtils.getCookie('mapProviders').split(',').forEach(function(provider){ } else {
[].forEach.call($('.map-provider'), function(li){
if($(li).text() == provider){
$(li).find('input:checkbox').prop('checked', true);
}else{
$(li).find('input:checkbox').prop('checked', false);
}
});
mapProviders[provider].addTo(map);
});
}else{
mapProviders.MapQuest.addTo(map); mapProviders.MapQuest.addTo(map);
} }
$(document).on('cookieUpdate', function(){ $(document).on('cookieUpdate', function () {
for(var key in mapProviders){ for (var key in mapProviders) {
map.removeLayer(mapProviders[key]); map.removeLayer(mapProviders[key]);
} }
if(cookieUtils.getCookie('mapProviders')){ if (cookieUtils.getCookie('mapProviders')) {
cookieUtils.getCookie('mapProviders').split(',').forEach(function(provider){ mapProviders[cookieUtils.getCookie('mapProviders')].addTo(map);
mapProviders[provider].addTo(map); } else {
});
}else{
mapProviders.MapQuest.addTo(map); mapProviders.MapQuest.addTo(map);
} }
}); });
$("body").on("click", ".map-provider", function (e) { $("body").on("click", ".map-provider", function (e) {
var title = $(this).text(); var providerName = $(this).parent().text();
var providers = cookieUtils.getCookie('mapProviders') && cookieUtils.getCookie('mapProviders')!=''?cookieUtils.getCookie('mapProviders').split(','):[]; console.log($(this).parent().text());
console.log(providerName);
if ($(this).find("input:checkbox").is(":checked")) { if ($(this).is(":checked")) {
providers.push(title); cookieUtils.setCookie('mapProviders', providerName, 0);
cookieUtils.setCookie('mapProviders', providers, 0);
$(document).trigger('cookieUpdate'); $(document).trigger('cookieUpdate');
} else { } else {
providers.splice(providers.indexOf(title), 1); providerName = '';
cookieUtils.setCookie('mapProviders', providers, 0); cookieUtils.setCookie('mapProviders', providerName, 0);
$(document).trigger('cookieUpdate'); $(document).trigger('cookieUpdate');
} }
......
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