miércoles, 13 de julio de 2016

Another choice for CKAN Maps instead of Mapquest

This week the visualization of maps inside of CKAN has been broken.

The default provider of layers (MapQuest) has changed its policy, and we haven't much time to react.

This is an example of map with the change:

To solve this, we need to change the default layer provider in the CKAN configuration file (geoview and spatial plugins) and in the default viewer (reclineView plugin).

We have choose http://www.thunderforest.com/. Specifically this visualization: http://www.thunderforest.com/maps/neighbourhood/

These are the steps to follow to do this change:

a) CKAN Configuration

In CKAN configuration file we must add these lines after the entry ckan.plugins:

ckanext.spatial.common_map.type = custom
ckanext.spatial.common_map.custom.url = http://tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png
ckanext.spatial.common_map.attribution = Maps &copy; <ahref="http://www.thunderforest.com">Thunderforest</a>, Data &copy; <aa href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>

b) Default viewer

Edit the file recline.js, which is stored in the path:

/usr/lib/ckan/default/src/ckan/ckanext/reclineview/theme/public/vendor/recline/recline.js is CKAN 2.5


/usr/lib/ckan/default/src/ckan/ckanext/reclinepreview/theme/public/vendor/recline/recline.js in CKAN 2.2

In this file there are two variables with this values:

var mapUrl = "//otile{s}-s.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png";   
var osmAttribution = 'Map data &copy; 2011 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">';

We must change the two values for these:

mapUrl = "//tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png";
osmAttribution = 'Maps &copy; <a href="http://www.thunderforest.com">Thunderforest</a>, Data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>';

c) Restart Apache2 and Nginx

With that steps the visualization of maps will be fine again.

We hope this information helps you.