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' } %>
190 function getPosition() {
191 return getMapCenter();
194 function setPosition(lat, lon, zoom) {
195 var centre = new OpenLayers.LonLat(lon, lat);
197 setMapCenter(centre, zoom);
200 removeMarkerFromMap(marker);
202 marker = addMarkerToMap(centre, getArrowIcon());
205 function updateLocation() {
206 var lonlat = getMapCenter();
207 var zoom = map.getZoom();
208 var layers = getMapLayers();
209 var extents = getMapExtent();
210 var expiry = new Date();
215 objtype = "<%= object_type %>";
216 objid = <%= object_id %>;
219 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
221 expiry.setYear(expiry.getFullYear() + 10);
222 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
225 function resizeContent() {
226 var content = $("content");
227 var rightMargin = parseInt(getStyle(content, "right"));
228 var bottomMargin = parseInt(getStyle(content, "bottom"));
230 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
231 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
234 function resizeMap() {
235 var centre = map.getCenter();
236 var zoom = map.getZoom();
237 var sidebar_width = $("sidebar").offsetWidth;
239 if (sidebar_width > 0) {
240 sidebar_width = sidebar_width + 5
243 $("map").style.left = (sidebar_width) + "px";
244 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
245 $("map").style.height = ($("content").offsetHeight - 2) + "px";
247 map.setCenter(centre, zoom);
250 function handleResize() {
251 if (brokenContentSize) {
260 window.onload = handleResize;
261 window.onresize = handleResize;
263 <% if params['action'] == 'export' %>
264 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>