Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify basemaps #545

Open
wants to merge 1 commit into
base: 2.8.x-qgis_server
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions geonode/client/templates/leaflet/layers/layer_leaflet_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,13 @@
attribution: '© unesco'
});

var OpenMapSurfer_Roads = L.tileLayer('http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}', {
maxZoom: 20,
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});

// not yet available
// var unesco_white = L.tileLayer(
// 'http://en.unesco.org/tiles/white/{z}/{x}/{y}.png', {
// attribution: '&copy; unesco'
// });

var base_maps = {
"OpenMapSurfer_Roads": OpenMapSurfer_Roads,
'OpenStreetMap': osm
};
var base_maps = {};

{# Extra basemap tiles from LEAFLET_CONFIG #}
{% if LEAFLET_CONFIG and LEAFLET_CONFIG.TILES %}
Expand Down
46 changes: 23 additions & 23 deletions geonode/client/templates/leaflet/maps/map_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,30 @@
L.tileLayer.betterWms = function (url, options) {
return new L.TileLayer.BetterWMS(url, options);
};
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});

var unesco = L.tileLayer(
'http://en.unesco.org/tiles/{z}/{x}/{y}.png', {
attribution: '&copy; unesco'
});

var unesco_geodata = L.tileLayer(
'http://en.unesco.org/tiles/geodata/{z}/{x}/{y}.png', {
attribution: '&copy; unesco'
});

var OpenMapSurfer_Roads = L.tileLayer('http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}', {
maxZoom: 20,
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});

var base_maps = {
"OpenMapSurfer_Roads": OpenMapSurfer_Roads,
'OpenStreetMap': osm
};
var base_maps = {};
{# it is likely the basemap will be shown twice if the map creation has fetched the base map from settings #}
{# otherwise, this to anticipate the old map when this new changes haven't applied yet #}
{% if LEAFLET_CONFIG and LEAFLET_CONFIG.TILES %}
var basemap_layers = new Array({{ LEAFLET_CONFIG.TILES|length }});
{# construct the background layer object #}
{% for tile in LEAFLET_CONFIG.TILES %}
basemap_layers[{{ forloop.counter0 }}] = L.tileLayer('{{ tile.1 }}',{
attribution: '{{ tile.2|safe }}'});
{% endfor %}
base_maps = {
{% for tile in LEAFLET_CONFIG.TILES %}
'{{ tile.0 }}': basemap_layers[{{ forloop.counter0 }}]{% if not forloop.last %},{% endif %}
{% endfor %}
};
{% else %}
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});
base_maps = {
'OpenStreetMap': osm
};
{% endif %}

var overlay_layer = {};

Expand Down Expand Up @@ -164,7 +165,6 @@
L.control.watermark({ position: 'bottomright' }).addTo(map);

// L.control.measureControl.addTo(map);
map.addLayer(OpenMapSurfer_Roads);

{% if layer_bbox %}
zoom_to_box(map, [{{ layer_bbox }}]);
Expand Down
88 changes: 59 additions & 29 deletions geonode/client/templates/leaflet/maps/map_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,36 +150,46 @@ <h4 class="modal-title">Save Map</h4>
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
});

var OpenMapSurfer_Roads = L.tileLayer('http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}', {
maxZoom: 20,
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});

{% if create %}
all_layers = {
'OpenMapSurfer_Roads': {
'title': 'OpenMapSurfer Roads',
'name': 'OpenMapSurfer_Roads',
'url': OpenMapSurfer_Roads._url,
'layer': OpenMapSurfer_Roads,
'visibility': true,
'group': 'background',
'zIndex': 0
},
'osm': {
'title': 'OpenStreetMap',
'name': 'osm',
'url': osm._url,
'layer': osm,
'visibility': false,
'group': 'background',
'zIndex': 1
}
};
all_layers_list.push('OpenMapSurfer_Roads');
all_layers_list.push('osm');

active_background_layer = OpenMapSurfer_Roads;
{% if LEAFLET_CONFIG and LEAFLET_CONFIG.TILES %}
var basemap_layers = new Array({{ LEAFLET_CONFIG.TILES|length }});
{# construct the background layer object #}
{% for tile in LEAFLET_CONFIG.TILES %}
basemap_layers[{{ forloop.counter0 }}] = L.tileLayer('{{ tile.1 }}',{
attribution: '{{ tile.2|safe }}'});
all_layers_list.push('{{ tile.0 }}');
{% endfor %}
{# use the object in the all_layers#}
all_layers = {
{% for tile in LEAFLET_CONFIG.TILES %}
'{{ tile.0 }}': {
'title': '{{ tile.0 }}',
'name': '{{ tile.0 }}',
'url': basemap_layers[{{ forloop.counter0 }}]._url,
'layer': basemap_layers[{{ forloop.counter0 }}],
'visibility': {% if forloop.counter0 == 0 %} true {% else %} false {% endif %},
'group': 'background',
'zIndex': 0
}{% if not forloop.last %},{% endif %}
{% endfor %}
};
active_background_layer = basemap_layers[0];
{% else %}
{# set settings.LEAFLET_CONFIG if reaches this part #}
all_layers = {
'osm': {
'title': 'OpenStreetMap',
'name': 'osm',
'url': osm._url,
'layer': osm,
'visibility': false,
'group': 'background',
'zIndex': 1
}
};
all_layers_list.push('osm');
active_background_layer = osm;
{% endif %}
{% else %}
all_layers = {};
all_layers_list = [];
Expand Down Expand Up @@ -584,6 +594,26 @@ <h4 class="modal-title">Save Map</h4>
{% endif %}
}
{% endfor %}

{# use case: add default basemap for embed iframe map #}
if (all_layers_list && all_layers_list.length == 0) {
all_layers = {
'osm': {
'title': 'OpenStreetMap',
'name': 'osm',
'url': osm._url,
'layer': osm,
'visibility': true,
'group': 'background',
'zIndex': 1
}
};
all_layers_list.push('osm');
active_background_layer = osm;
active_background_layer.addTo(map);
active_background_layer.setZIndex(0);
}

populate_background_layer(all_layers_list, all_layers);
{% if map and map.center_x %}
// console.log("{{ map.center_x }}, {{ map.center_y }}), {{ map.zoom }}");
Expand Down
16 changes: 8 additions & 8 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,19 +1012,19 @@
# http://leaflet-extras.github.io/leaflet-providers/preview/

# Base map
('OpenMapSurfer_Roads',
'http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}',
'Imagery from <a href="http://giscience.uni-hd.de/">'
'GIScience Research Group @ University of Heidelberg</a> '
'&mdash; Map data &copy;'
' <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
),
('OpenStreetMap',
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> '
'contributors'
),

('Terrain',
'http://a.tile.stamen.com/terrain/{z}/{x}/{y}.png',
'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://openstreetmap.org">OpenStreetMap</a> contributors, \
<a href="http://creativecommons.org/licenses/by-sa/2.0/"> \
CC-BY-SA</a>'),
# Stamen toner lite.
('Watercolor',
'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg',
Expand Down