|
1 | 1 | <%= error_messages_for 'tile_source' %>
|
2 | 2 |
|
3 |
| - |
4 | 3 | <div class="box tabular">
|
5 | 4 | <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 | + [l(:gtt_tile_sources_select_imagewms), 'ol.source.ImageWMS'], |
| 9 | + [l(:gtt_tile_sources_select_osm), 'ol.source.OSM'], |
| 10 | + [l(:gtt_tile_sources_select_tilewms), 'ol.source.TileWMS'], |
| 11 | + [l(:gtt_tile_sources_select_xyz), 'ol.source.XYZ'] |
| 12 | + ], selected: f.object.type ), |
| 13 | + { include_blank: l(:gtt_tile_sources_select), required: true } |
| 14 | + %> |
| 15 | + </p> |
7 | 16 | <p><%= f.check_box :baselayer %></p>
|
8 | 17 | <p><%= f.check_box :global %></p>
|
9 | 18 | <p><%= f.check_box :default %></p>
|
10 |
| - <p> <%= f.text_area :options_string, rows: 10, cols: 80 %> </p> |
| 19 | + <p> |
| 20 | + <%= f.text_area :options_string, rows: 10, cols: 80 %> |
| 21 | + <em class="info"><a href="#" onclick="loadExampleConfiguration(this);return false;"><%= l(:gtt_tile_sources_load_example) %></a></em>. |
| 22 | + </p> |
11 | 23 | </div>
|
12 | 24 |
|
| 25 | +<script> |
| 26 | + const tile_source_examples = { |
| 27 | + 'ol.source.ImageWMS': { |
| 28 | + "url": "https://www.example.com/geoserver/wms", |
| 29 | + "params": { |
| 30 | + "LAYERS": "schema:mydata" |
| 31 | + }, |
| 32 | + "ratio": 1, |
| 33 | + "serverType": "geoserver" |
| 34 | + }, |
| 35 | + 'ol.source.OSM': { |
| 36 | + "url": "https://tile.openstreetmap.jp/{z}/{x}/{y}.png", |
| 37 | + "custom": "19/34.74701/135.35740", |
| 38 | + "crossOrigin": null, |
| 39 | + "attributions": "<a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a>" |
| 40 | + }, |
| 41 | + 'ol.source.TileWMS': { |
| 42 | + "url": "https://www.example.com/geoserver/wms", |
| 43 | + "params": { |
| 44 | + "TILED": true, |
| 45 | + "LAYERS": "schema:mydata" |
| 46 | + }, |
| 47 | + "serverType": "geoserver" |
| 48 | + }, |
| 49 | + 'ol.source.XYZ': { |
| 50 | + "url": "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png", |
| 51 | + "projection": "EPSG:3857", |
| 52 | + "attributions": "<a href='https://maps.gsi.go.jp/development/ichiran.html' target='_blank'>地理院タイル</a>" |
| 53 | + } |
| 54 | + }; |
13 | 55 |
|
14 |
| - |
| 56 | + function loadExampleConfiguration(obj) { |
| 57 | + var config = tile_source_examples[document.getElementById("tile_source_type").value]; |
| 58 | + if (config) { |
| 59 | + document.getElementById("tile_source_options_string").innerHTML = JSON.stringify(config, undefined, 2);; |
| 60 | + } |
| 61 | + } |
| 62 | +</script> |
0 commit comments