Skip to content

Commit e790b65

Browse files
dkastlsanak
authored andcommitted
Adds selector and examples
Signed-off-by: Daniel Kastl <[email protected]>
1 parent ea098ed commit e790b65

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed
Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,53 @@
11
<%= error_messages_for 'tile_source' %>
22

3-
43
<div class="box tabular">
54
<p><%= f.text_field :name, required: true, size: 25 %></p>
6-
<p><%= f.text_field :type, required: true, size: 25 %></p>
5+
<p>
6+
<%= f.select :type,
7+
options_for_select([
8+
['ol.source.OSM', 'ol.source.OSM'],
9+
['ol.source.TileWMS', 'ol.source.TileWMS'],
10+
['ol.source.XYZ', 'ol.source.XYZ']
11+
], selected: f.object.type ),
12+
{ include_blank: l(:gtt_tile_sources_select), required: true }
13+
%>
14+
</p>
715
<p><%= f.check_box :baselayer %></p>
816
<p><%= f.check_box :global %></p>
917
<p><%= f.check_box :default %></p>
10-
<p> <%= f.text_area :options_string, rows: 10, cols: 80 %> </p>
18+
<p>
19+
<%= f.text_area :options_string, rows: 10, cols: 80 %>
20+
<em class="info"><a href="#" onclick="loadExampleConfiguration(this);return false;"><%= l(:gtt_tile_sources_load_example) %></a></em>.
21+
</p>
1122
</div>
1223

24+
<script>
25+
const tile_source_examples = {
26+
'ol.source.OSM': {
27+
"url": "https://tile.openstreetmap.jp/{z}/{x}/{y}.png",
28+
"custom": "19/34.74701/135.35740",
29+
"crossOrigin": null,
30+
"attributions": "<a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a>"
31+
},
32+
'ol.source.TileWMS': {
33+
"url": "https://www.example.com/geoserver/wms",
34+
"params": {
35+
"TILED": true,
36+
"LAYERS": "raster:mydata"
37+
},
38+
"serverType": "geoserver"
39+
},
40+
'ol.source.XYZ': {
41+
"url": "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
42+
"projection": "EPSG:3857",
43+
"attributions": "<a href='https://maps.gsi.go.jp/development/ichiran.html' target='_blank'>地理院タイル</a>"
44+
}
45+
};
1346

14-
47+
function loadExampleConfiguration(obj) {
48+
var config = tile_source_examples[document.getElementById("tile_source_type").value];
49+
if (config) {
50+
document.getElementById("tile_source_options_string").innerHTML = JSON.stringify(config, undefined, 2);;
51+
}
52+
}
53+
</script>

config/locales/en.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ en:
4242

4343
geocoder_options: "Geocoder Options"
4444

45-
gtt_tile_sources_info: Select the tile sources that should be available in this project.
45+
gtt_tile_sources_info: "Select the tile sources that should be available in this project."
46+
gtt_tile_sources_select: "-- Select type --"
47+
gtt_tile_sources_load_example: "Load example configuration"
4648

4749
gtt_settings_general_center_lon: "Default map center longitude"
4850
gtt_settings_general_center_lat: "Default map center latitude"

config/locales/ja.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ ja:
4343
geocoder_options: "ジオコーダのオプション"
4444

4545
gtt_tile_sources_info: このプロジェクトで使用できるタイルソースを選択します。
46+
gtt_tile_sources_select: "-- Select type --"
47+
gtt_tile_sources_load_example: "Load example configuration"
4648

4749
gtt_settings_general_center_lon: "既定の地図中心経度"
4850
gtt_settings_general_center_lat: "既定の地図中心緯度"

0 commit comments

Comments
 (0)