LoginSignup
4
5

More than 5 years have passed since last update.

CKANの地図を変更する

Last updated at Posted at 2016-07-22

CKANにてckanext-spatial もしくは ckanext-geoviewを使用しててMapQuestの地図表示してる場合、気がつけば地図データが以下のものに変わっちゃってるんじゃないでしょうか。

0.png

こちら、MapQuest がタイル地図のダイレクトアクセスのサポートやめちゃうたのが理由だったりします。
詳しくはこちら

そんなわけで、CKANで使用する地図を他の地図に切り替える方法の例をあげます。

下記は、Maptiles への切り替えの例。

まず、ini(production.iniとか)ファイルの変更

 ckanext.spatial.common_map.type = custom
 ckanext.spatial.common_map.custom.url = http://{s}.osm.maptiles.xyz/{z}/{x}/{y}.png
 ckanext.spatial.common_map.attribution = &copy <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles provided by <a     href="https://maptiles.xyz">MapTiles</a>.

ただ、上記だたおOpenLayer側のViewerのurlのバインド変数{s}をよろしく扱ってくれないので、あんまり良くないのかもしれませんが
OLviewerを使用している方は、下記のように書いちゃった方よいかもしれません。

-    ckanext.spatial.common_map.custom.url = http://{s}.osm.maptiles.xyz/{z}/{x}/{y}.png
+    ckanext.spatial.common_map.custom.url = http://c.osm.maptiles.xyz/{z}/{x}/{y}.png

cは[abc]ですね、そのどれかを。

それで、これだけだと、reclineが表示している地図が切り替わりません。csvとかから緯度経度指定して地図を表示する機能ですね。
そちらを切り替えるには、

ckanext/reclineview/theme/public/vendor/recline/recline.jsの2281行目あたりを修正します。

-    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">';
-    var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution ,subdomains: '1234'});
+    var mapUrl = "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
+    var osmAttribution = '©<a href="http://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors';
+    var bg = new L.TileLayer(mapUrl, {maxZoom: 19, attribution: osmAttribution});

他のタイル地図プロバイダも試したいって方は、こちらに色々書いてます。
他にも必要な修正箇所がありそうですが、随時メモれればと。

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5