Skip to content

Commit

Permalink
Replace Mapquest tiels by Stamen by default
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Aug 3, 2016
1 parent 71f59cd commit f59e3a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Common base layers for Map Widgets

The geospatial view plugins support the same base map configurations than the ckanext-spatial `widgets`_.

Check the following page to learn how to choose a different base map layer (MapQuest Open, MapBox or custom):
Check the following page to learn how to choose a different base map layer (Stamen, MapBox or custom):

http://docs.ckan.org/projects/ckanext-spatial/en/latest/map-widgets.html

Expand Down
14 changes: 5 additions & 9 deletions ckanext/geoview/public/js/common_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
leafletBaseLayerOptions) {

var isHttps = window.location.href.substring(0, 5).toLowerCase() === 'https';
var mapConfig = mapConfig || {type: 'mapquest'};
var mapConfig = mapConfig || {type: 'stamen'};
var leafletMapOptions = leafletMapOptions || {};
var leafletBaseLayerOptions = jQuery.extend(leafletBaseLayerOptions, {
maxZoom: 18
Expand All @@ -55,14 +55,10 @@
if (mapConfig.tms) leafletBaseLayerOptions.tms = mapConfig.tms;
leafletBaseLayerOptions.attribution = mapConfig.attribution;
} else {
// MapQuest OpenStreetMap base map
if (isHttps) {
baseLayerUrl = '//otile{s}-s.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
} else {
baseLayerUrl = '//otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
}
leafletBaseLayerOptions.subdomains = mapConfig.subdomains || '1234';
leafletBaseLayerOptions.attribution = mapConfig.attribution || 'Map data &copy; OpenStreetMap contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="//developer.mapquest.com/content/osm/mq_logo.png">';
// Default to Stamen base map
baseLayerUrl = 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png';
leafletBaseLayerOptions.subdomains = mapConfig.subdomains || 'abcd';
leafletBaseLayerOptions.attribution = mapConfig.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>). Data by <a href="http://openstreetmap.org">OpenStreetMap</a> (<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>)';
}

var baseLayer = new L.TileLayer(baseLayerUrl, leafletBaseLayerOptions);
Expand Down
23 changes: 7 additions & 16 deletions ckanext/geoview/public/js/ol2_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,13 @@
attribution: mapConfig.attribution
});
} else {
// MapQuest OpenStreetMap base map
if (isHttps) {
var urls = ['//otile1-s.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png',
'//otile2-s.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png',
'//otile3-s.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png',
'//otile4-s.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png'];

} else {
var urls = ['//otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png',
'//otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png',
'//otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png',
'//otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png'];
}
var attribution = mapConfig.attribution || 'Map data &copy; OpenStreetMap contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="//developer.mapquest.com/content/osm/mq_logo.png">';

baseMapLayer = new OpenLayers.Layer.OSM('MapQuest OSM', urls, {
// Stamen base map
var urls = ['//stamen-tiles-a.a.ssl.fastly.net/terrain/${z}/${x}/${y}.png',
'//stamen-tiles-b.a.ssl.fastly.net/terrain/${z}/${x}/${y}.png',
'//stamen-tiles-c.a.ssl.fastly.net/terrain/${z}/${x}/${y}.png',
'//stamen-tiles-d.a.ssl.fastly.net/terrain/${z}/${x}/${y}.png'];
var 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>). Data by <a href="http://openstreetmap.org">OpenStreetMap</a> (<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>)';
baseMapLayer = new OpenLayers.Layer.OSM('Base Map', urls, {
attribution: attribution});
}

Expand Down

0 comments on commit f59e3a5

Please sign in to comment.