]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_key.html.erb
62ab2105ee5b64534ec99883e716000f693ab1c7
[rails.git] / app / views / site / _key.html.erb
1 <% content_for :left_menu do %>
2 <%= link_to_function t('site.key.map_key'), "showKey();", { :title => t('site.key.map_key_tooltip') } %>
3 <% end %>
4
5 <script type="text/javascript">
6 <!--
7
8   function showKeyEntry(image, text) {
9     var ret = '';
10     ret += '<tr>';
11     ret += '  <td class="mapkey-table-key" align="center">';
12     ret += '    <img src="/images/mapkey/' + image + '" />';
13     ret += '  </td>';
14     ret += '  <td class="mapkey-table-value">';
15     ret +=      text;
16     ret += '  </td>';
17     ret += '</tr>';
18     return ret;
19   }
20   function showKey() {
21     var zoomlevel = map.getZoom();
22     var mapkey_values = new Array();
23     mapkey_values['heading']      = "<%= t'site.key.table.heading' %>";
24     mapkey_values['motorway']     = "<%= t'site.key.table.entry.motorway' %>";
25     mapkey_values['trunk']        = "<%= t'site.key.table.entry.trunk' %>";
26     mapkey_values['primary']      = "<%= t'site.key.table.entry.primary' %>";
27     mapkey_values['secondary']    = "<%= t'site.key.table.entry.secondary' %>";
28     mapkey_values['unclassified'] = "<%= t'site.key.table.entry.unclassified' %>";
29     mapkey_values['unsurfaced']   = "<%= t'site.key.table.entry.unsurfaced' %>";
30     mapkey_values['track']        = "<%= t'site.key.table.entry.track' %>";
31     mapkey_values['byway']        = "<%= t'site.key.table.entry.byway' %>";
32     mapkey_values['bridleway']    = "<%= t'site.key.table.entry.bridleway' %>";
33     mapkey_values['cycleway']     = "<%= t'site.key.table.entry.cycleway' %>";
34     mapkey_values['footway']      = "<%= t'site.key.table.entry.footway' %>";
35     mapkey_values['rail']         = "<%= t'site.key.table.entry.rail' %>";
36     mapkey_values['subway']       = "<%= t'site.key.table.entry.subway' %>";
37     mapkey_values['tram']         = "<%= t'site.key.table.entry.tram' %>";
38     mapkey_values['cable']        = "<%= t'site.key.table.entry.cable' %>";
39     mapkey_values['runway']       = "<%= t'site.key.table.entry.runway' %>";
40     mapkey_values['apron']        = "<%= t'site.key.table.entry.apron' %>";
41     mapkey_values['admin']        = "<%= t'site.key.table.entry.admin' %>";
42     mapkey_values['forest']       = "<%= t'site.key.table.entry.forest' %>";
43     mapkey_values['wood']         = "<%= t'site.key.table.entry.wood' %>";
44     mapkey_values['golf']         = "<%= t'site.key.table.entry.golf' %>";
45     mapkey_values['park']         = "<%= t'site.key.table.entry.park' %>";
46     mapkey_values['resident']     = "<%= t'site.key.table.entry.resident' %>";
47     mapkey_values['tourist']      = "<%= t'site.key.table.entry.tourist' %>";
48     mapkey_values['common']       = "<%= t'site.key.table.entry.common' %>";
49     mapkey_values['retail']       = "<%= t'site.key.table.entry.retail' %>";
50     mapkey_values['industrial']   = "<%= t'site.key.table.entry.industrial' %>";
51     mapkey_values['commercial']   = "<%= t'site.key.table.entry.commercial' %>";
52     mapkey_values['heathland']    = "<%= t'site.key.table.entry.heathland' %>";
53     mapkey_values['lake']         = "<%= t'site.key.table.entry.lake' %>";
54     mapkey_values['farm']         = "<%= t'site.key.table.entry.farm' %>";
55     mapkey_values['brownfield']   = "<%= t'site.key.table.entry.brownfield' %>";
56     mapkey_values['cemetery']     = "<%= t'site.key.table.entry.cemetery' %>";
57     mapkey_values['allotments']   = "<%= t'site.key.table.entry.allotments' %>";
58     mapkey_values['pitch']        = "<%= t'site.key.table.entry.pitch' %>";
59     mapkey_values['centre']       = "<%= t'site.key.table.entry.centre' %>";
60     mapkey_values['reserve']      = "<%= t'site.key.table.entry.reserve' %>";
61     mapkey_values['military']     = "<%= t'site.key.table.entry.military' %>";
62     mapkey_values['school']       = "<%= t'site.key.table.entry.school' %>";
63     mapkey_values['building']     = "<%= t'site.key.table.entry.building' %>";
64     mapkey_values['station']      = "<%= t'site.key.table.entry.station' %>";
65     mapkey_values['summit']       = "<%= t'site.key.table.entry.summit' %>";
66     mapkey_values['tunnel']       = "<%= t'site.key.table.entry.tunnel' %>";
67     mapkey_values['bridge']       = "<%= t'site.key.table.entry.bridge' %>";
68     mapkey_values['private']      = "<%= t'site.key.table.entry.private' %>";
69     mapkey_values['permissive']   = "<%= t'site.key.table.entry.permissive' %>";
70     mapkey_values['destination']  = "<%= t'site.key.table.entry.destination' %>";
71     mapkey_values['construction'] = "<%= t'site.key.table.entry.construction' %>";
72
73     var out = '';
74     var suffix = '';
75
76     out += '<div id="mapkey">';
77     out += '<h3>' + i18n(mapkey_values['heading'], { zoom_level: zoomlevel }) + "</h3>";
78     out += '<table class="mapkey-table">';
79     out += showKeyEntry('motorway.png', mapkey_values['motorway']);
80     
81     if (zoomlevel >= 12) {
82         suffix = 12;
83     }
84     out += showKeyEntry('trunk' + suffix + '.png', mapkey_values['trunk']);
85     if (zoomlevel >= 7) {
86         out += showKeyEntry('primary' + suffix + '.png', mapkey_values['primary']);
87     }
88     if (zoomlevel >= 9) {
89         out += showKeyEntry('secondary' + suffix + '.png', mapkey_values['secondary']);
90     }
91     if (zoomlevel >= 10) {
92         suffix = '';
93         if (zoomlevel >= 13) { suffix="13"; }
94         out += showKeyEntry('unclassified' + suffix + '.png', mapkey_values['unclassified']);
95     }
96     if (zoomlevel >= 13) {
97         out += showKeyEntry('unsurfaced.png', mapkey_values['unsurfaced']);
98         out += showKeyEntry('track.png', mapkey_values['track']);
99         out += showKeyEntry('byway.png', mapkey_values['byway']);
100         out += showKeyEntry('bridleway.png', mapkey_values['bridleway']);
101         out += showKeyEntry('cycleway.png', mapkey_values['cycleway']);
102         out += showKeyEntry('footway.png', mapkey_values['footway']);
103     }
104     if (zoomlevel >= 8) {
105         suffix = '';
106         if (zoomlevel >= 13) { suffix = "13"; }
107         out += showKeyEntry('rail' + suffix + '.png', mapkey_values['rail']);
108     }
109     if (zoomlevel >= 13) {
110         out += showKeyEntry('subway.png', mapkey_values['subway']);
111         out += showKeyEntry('tram.png', mapkey_values['tram']);
112     }
113     if (zoomlevel >= 12) {
114         out += showKeyEntry('cable.png', mapkey_values['cable']);
115     }
116     if (zoomlevel >= 11) {
117         out += showKeyEntry('runway.png', mapkey_values['runway']);
118     }
119     if (zoomlevel >= 12) {
120         out += showKeyEntry('apron.png', mapkey_values['apron']);
121     }
122     out += showKeyEntry('admin.png', mapkey_values['admin']);
123     if (zoomlevel >= 9) {
124         out += showKeyEntry('forest.png', mapkey_values['forest']);
125     }
126     if (zoomlevel >= 10) {
127         out += showKeyEntry('wood.png', mapkey_values['wood']);
128         out += showKeyEntry('golf.png', mapkey_values['golf']);
129         out += showKeyEntry('park.png', mapkey_values['park']);
130     }
131     if (zoomlevel >= 8) {
132         out += showKeyEntry('resident.png', mapkey_values['resident']);
133     }
134     if (zoomlevel >= 10) {
135         out += showKeyEntry('tourist.png', mapkey_values['tourist']);
136         out += showKeyEntry('common.png', mapkey_values['common']);
137         out += showKeyEntry('retail.png', mapkey_values['retail']);
138         out += showKeyEntry('industrial.png', mapkey_values['industrial']);
139         out += showKeyEntry('commercial.png', mapkey_values['commercial']);
140         out += showKeyEntry('heathland.png', mapkey_values['heathland']);
141     }
142     if (zoomlevel >= 8) {
143         out += showKeyEntry('lake.png', mapkey_values['lake']);
144     }
145     if (zoomlevel >= 10) {
146         out += showKeyEntry('farm.png', mapkey_values['farm']);
147         out += showKeyEntry('brownfield.png', mapkey_values['brownfield']);
148     }
149     if (zoomlevel >= 11) {
150         out += showKeyEntry('cemetery.png', mapkey_values['cemetery']);
151         out += showKeyEntry('allotments.png', mapkey_values['allotments']);
152         out += showKeyEntry('pitch.png', mapkey_values['pitch']);
153         out += showKeyEntry('centre.png', mapkey_values['centre']);
154         out += showKeyEntry('reserve.png', mapkey_values['reserve']);
155         out += showKeyEntry('military.png', mapkey_values['military']);
156     }
157     if (zoomlevel >= 12) {
158         out += showKeyEntry('school.png', mapkey_values['school']);
159         out += showKeyEntry('building.png', mapkey_values['building']);
160         out += showKeyEntry('station.png', mapkey_values['station']);
161         out += showKeyEntry('summit.png', mapkey_values['summit']);
162         out += showKeyEntry('tunnel.png', mapkey_values['tunnel']);
163     }
164     if (zoomlevel >= 13) {
165         out += showKeyEntry('bridge.png', mapkey_values['bridge']);
166     }
167     if (zoomlevel >= 15) {
168         out += showKeyEntry('private.png', mapkey_values['private']);
169         out += showKeyEntry('permissive.png', mapkey_values['permissive']);
170         out += showKeyEntry('destination.png', mapkey_values['destination']);
171     }
172     if (zoomlevel >= 12) {
173         out += showKeyEntry('construction.png', mapkey_values['construction']);
174     }
175         
176     out += "</table>";
177     out += "</div>";
178
179     updateSidebar("<%= t('site.key.map_key') %>", out);
180     openSidebar({ width: "210px" });
181   }
182
183   function updateKey() {
184     if (sidebarOpen("<%= t('site.key.map_key') %>")) 
185     {
186       showKey();
187     }
188   }
189 // -->
190 </script>