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>
21 <a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
22 <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
26 <div id="attribution">
29 <td align="left"><%= t'site.index.license.license_url' %></td>
30 <td align="right"><%= t'site.index.license.project_url' %></td>
33 <td colspan="2" align="center"><%=
34 t'site.index.license.notice',
35 :license_name => t('site.index.license.license_name'),
36 :project_name => t('site.index.license.project_name')
43 if params['mlon'] and params['mlat']
45 mlon = h(params['mlon'])
46 mlat = h(params['mlat'])
49 if params['node'] or params['way'] or params['relation']
55 object_id = h(params['node'])
58 object_id = h(params['way'])
59 elsif params['relation']
60 object_type = 'relation'
61 object_id = h(params['relation'])
65 if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
67 minlon = h(params['minlon'])
68 minlat = h(params['minlat'])
69 maxlon = h(params['maxlon'])
70 maxlat = h(params['maxlat'])
71 box = true if params['box']=="yes"
75 # Decide on a lat lon to initialise the map with. Various ways of doing this
76 if params['lon'] and params['lat']
77 lon = h(params['lon'])
78 lat = h(params['lat'])
79 zoom = h(params['zoom'] || '5')
80 layers = h(params['layers'])
82 elsif params['mlon'] and params['mlat']
83 lon = h(params['mlon'])
84 lat = h(params['mlat'])
85 zoom = h(params['zoom'] || '12')
86 layers = h(params['layers'])
88 elsif cookies.key?("_osm_location")
89 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
90 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
95 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
99 minlon = session[:location][:minlon]
100 minlat = session[:location][:minlat]
101 maxlon = session[:location][:maxlon]
102 maxlat = session[:location][:maxlat]
106 zoom = h(params['zoom'] || '5')
109 layers = h(params['layers'])
113 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
114 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
115 <%= javascript_include_tag 'map.js' %>
117 <script type="text/javascript" defer="defer">
119 var brokenContentSize = $("content").offsetWidth == 0;
123 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
126 map = createMap("map");
128 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
129 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
130 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
131 map.addLayer(map.dataLayer);
134 <% unless object_zoom %>
136 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
141 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
142 Event.observe(window, 'load', function() { addBoxToMap(bbox) });
145 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
146 var zoom = <%= zoom %>;
148 <% if params['scale'] and params['scale'].length > 0 then %>
149 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
152 setMapCenter(centre, zoom);
158 <% if !layers.nil? and !layers.empty? %>
159 setMapLayers("<%= layers %>");
163 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
167 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
169 <% if object_type != "node" %>
173 addObjectToMap(url, <%= object_zoom %>);
176 map.events.register("moveend", map, updateLocation);
177 map.events.register("changelayer", map, updateLocation);
182 function toggleData() {
183 if (map.dataLayer.visibility) {
184 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
185 } else if (map.dataLayer.active) {
190 function getPosition() {
191 return getMapCenter();
198 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
199 var centre = new OpenLayers.LonLat(lon, lat);
201 if (min_lon && min_lat && max_lon && max_lat) {
202 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
206 setMapCenter(centre, zoom);
210 removeMarkerFromMap(marker);
212 marker = addMarkerToMap(centre, getArrowIcon());
215 function updateLocation() {
216 var lonlat = getMapCenter();
217 var zoom = map.getZoom();
218 var layers = getMapLayers();
219 var extents = getMapExtent();
220 var expiry = new Date();
225 objtype = "<%= object_type %>";
226 objid = <%= object_id %>;
229 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
231 expiry.setYear(expiry.getFullYear() + 10);
232 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
235 function resizeContent() {
236 var content = $("content");
237 var rightMargin = parseInt(getStyle(content, "right"));
238 var bottomMargin = parseInt(getStyle(content, "bottom"));
240 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
241 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
244 function resizeMap() {
245 var centre = map.getCenter();
246 var zoom = map.getZoom();
247 var sidebar_width = $("sidebar").offsetWidth;
249 if (sidebar_width > 0) {
250 sidebar_width = sidebar_width + 5
253 $("map").style.left = (sidebar_width) + "px";
254 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
255 $("map").style.height = ($("content").offsetHeight - 2) + "px";
257 map.setCenter(centre, zoom);
260 function handleResize() {
261 if (brokenContentSize) {
270 window.onload = handleResize;
271 window.onresize = handleResize;
273 <% if params['action'] == 'export' %>
274 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>