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 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
174 Event.observe(window, 'load', function() { addObjectToMap(url, <%= object_zoom %>) });
177 map.events.register("moveend", map, updateLocation);
178 map.events.register("changelayer", map, updateLocation);
183 function toggleData() {
184 if (map.dataLayer.visibility) {
185 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
186 } else if (map.dataLayer.active) {
191 function getPosition() {
192 return getMapCenter();
199 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
200 var centre = new OpenLayers.LonLat(lon, lat);
202 if (min_lon && min_lat && max_lon && max_lat) {
203 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
207 setMapCenter(centre, zoom);
211 removeMarkerFromMap(marker);
213 marker = addMarkerToMap(centre, getArrowIcon());
216 function updateLocation() {
217 var lonlat = getMapCenter();
218 var zoom = map.getZoom();
219 var layers = getMapLayers();
220 var extents = getMapExtent();
221 var expiry = new Date();
226 objtype = "<%= object_type %>";
227 objid = <%= object_id %>;
230 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
232 expiry.setYear(expiry.getFullYear() + 10);
233 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
236 function resizeContent() {
237 var content = $("content");
238 var rightMargin = parseInt(getStyle(content, "right"));
239 var bottomMargin = parseInt(getStyle(content, "bottom"));
241 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
242 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
245 function resizeMap() {
246 var centre = map.getCenter();
247 var zoom = map.getZoom();
248 var sidebar_width = $("sidebar").offsetWidth;
250 if (sidebar_width > 0) {
251 sidebar_width = sidebar_width + 5
254 $("map").style.left = (sidebar_width) + "px";
255 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
256 $("map").style.height = ($("content").offsetHeight - 2) + "px";
258 map.setCenter(centre, zoom);
261 function handleResize() {
262 if (brokenContentSize) {
271 window.onload = handleResize;
272 window.onresize = handleResize;
274 <% if params['action'] == 'export' %>
275 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>