1 <% content_for :greeting do %>
2 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
3 <%= link_to_function t('layouts.home'), "setPosition(#{@user.home_lat}, #{@user.home_lon}, 10)", { :title => t('layouts.home_tooltip') } %> |
7 <%= render :partial => 'sidebar', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
8 <%= render :partial => 'key' %>
9 <%= render :partial => 'search' %>
13 <p><%= t 'site.index.js_1' %></p>
14 <p><%= t 'site.index.js_2' %></p>
15 <p><%= t 'site.index.js_3' %></p>
23 <a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
24 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
27 <div id="attribution">
30 <td align="left"><%= t'site.index.license.license_url' %></td>
31 <td align="right"><%= t'site.index.license.project_url' %></td>
34 <td colspan="2" align="center"><%=
35 t'site.index.license.notice',
36 :license_name => t('site.index.license.license_name'),
37 :project_name => t('site.index.license.project_name')
44 if params['mlon'] and params['mlat']
46 mlon = h(params['mlon'])
47 mlat = h(params['mlat'])
50 if params['node'] or params['way'] or params['relation']
56 object_id = h(params['node'])
59 object_id = h(params['way'])
60 elsif params['relation']
61 object_type = 'relation'
62 object_id = h(params['relation'])
66 if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
68 minlon = h(params['minlon'])
69 minlat = h(params['minlat'])
70 maxlon = h(params['maxlon'])
71 maxlat = h(params['maxlat'])
72 box = true if params['box']=="yes"
76 # Decide on a lat lon to initialise the map with. Various ways of doing this
77 if params['lon'] and params['lat']
78 lon = h(params['lon'])
79 lat = h(params['lat'])
80 zoom = h(params['zoom'] || '5')
81 layers = h(params['layers'])
83 elsif params['mlon'] and params['mlat']
84 lon = h(params['mlon'])
85 lat = h(params['mlat'])
86 zoom = h(params['zoom'] || '12')
87 layers = h(params['layers'])
89 elsif cookies.key?("_osm_location")
90 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
91 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
96 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
100 minlon = session[:location][:minlon]
101 minlat = session[:location][:minlat]
102 maxlon = session[:location][:maxlon]
103 maxlat = session[:location][:maxlat]
107 zoom = h(params['zoom'] || '5')
110 layers = h(params['layers'])
114 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
115 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
116 <%= javascript_include_tag 'map.js' %>
118 <script type="text/javascript" defer="defer">
120 var brokenContentSize = $("content").offsetWidth == 0;
124 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
127 map = createMap("map");
129 <% unless STATUS == :api_offline or STATUS == :database_offline %>
130 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
131 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
132 map.addLayer(map.dataLayer);
135 <% unless object_zoom %>
137 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
142 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
143 Event.observe(window, 'load', function() { addBoxToMap(bbox) });
146 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
147 var zoom = <%= zoom %>;
149 <% if params['scale'] and params['scale'].length > 0 then %>
150 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
153 setMapCenter(centre, zoom);
159 <% if !layers.nil? and !layers.empty? %>
160 setMapLayers("<%= layers %>");
164 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
168 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
170 <% if object_type != "node" %>
174 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
175 Event.observe(window, 'load', function() { addObjectToMap(url, <%= object_zoom %>) });
178 map.events.register("moveend", map, updateLocation);
179 map.events.register("changelayer", map, updateLocation);
184 function toggleData() {
185 if (map.dataLayer.visibility) {
186 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
187 } else if (map.dataLayer.active) {
192 function getPosition() {
193 return getMapCenter();
200 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
201 var centre = new OpenLayers.LonLat(lon, lat);
203 if (min_lon && min_lat && max_lon && max_lat) {
204 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
208 setMapCenter(centre, zoom);
212 removeMarkerFromMap(marker);
214 marker = addMarkerToMap(centre, getArrowIcon());
217 function updateLocation() {
218 var lonlat = getMapCenter();
219 var zoom = map.getZoom();
220 var layers = getMapLayers();
221 var extents = getMapExtent();
222 var expiry = new Date();
227 objtype = "<%= object_type %>";
228 objid = <%= object_id %>;
231 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
233 expiry.setYear(expiry.getFullYear() + 10);
234 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
237 function resizeContent() {
238 var content = $("content");
239 var rightMargin = parseInt(getStyle(content, "right"));
240 var bottomMargin = parseInt(getStyle(content, "bottom"));
242 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
243 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
246 function resizeMap() {
247 var centre = map.getCenter();
248 var zoom = map.getZoom();
249 var sidebar_width = $("sidebar").offsetWidth;
251 if (sidebar_width > 0) {
252 sidebar_width = sidebar_width + 5
255 $("map").style.left = (sidebar_width) + "px";
256 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
257 $("map").style.height = ($("content").offsetHeight - 2) + "px";
259 map.setCenter(centre, zoom);
262 function handleResize() {
263 if (brokenContentSize) {
272 window.onload = handleResize;
273 window.onresize = handleResize;
275 <% if params['action'] == 'export' %>
276 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>