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

o

/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.

Alternativa a MapQuest en CKAN

Esta semana los mapas de CKAN han dejado de visualizarse.

El proveedor por defecto de las capas (MapQuest) ha cambiado su política de repente y nos ha dejado poco tiempo para reaccionar.

Éste es el aspecto que tienen los mapas con el cambio:


Para solucionar esto, tenemos que cambiar de proveedor de capas en la Configuración de CKAN (para los plugins geoview y spatial) y en la visualización por defecto (para el plugin reclineView).

Nosotros nos hemos cambiado a http://www.thunderforest.com/. Concretamente a esta visualización: http://www.thunderforest.com/maps/neighbourhood/

Éstos son los pasos que hay que seguir:

a) Configuración de CKAN

En el fichero de configuración de CKAN añadimos estas lineas justo debajo de la entrada 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) Visualización por defecto

Editamos el fichero recline.js Que se encuentra en:

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

o

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

En este fichero se crean e inicializan estas variables:

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">';

Lo que tenemos que hacer es cambiar su valor por este otro:

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) Reiniciamos Apache2 y Nginx

Con estos pasos todos los mapas volverán a visualizarse correctamente.



Esperamos que estos pasos os sirvan de ayuda.