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><br/>
23 <a id="ReportBug">Report a problem</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 <!--Use stock OpenLayers for now, as the OSM one is missing some needed classes-->
115 <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
116 <!-- < %= javascript_include_tag '/openlayers/OpenLayers.js' % > -->
117 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
118 <%= javascript_include_tag 'openstreetbugs.js' %>
119 <%= javascript_include_tag 'map.js' %>
121 <script type="text/javascript" defer="defer">
123 var brokenContentSize = $("content").offsetWidth == 0;
127 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
129 function createBugCallBack() {
130 map.osbControl.deactivate();
131 document.getElementById("map_OpenLayers_Container").style.cursor = "default";
135 map = createMap("map");
137 <% unless STATUS == :api_offline or STATUS == :database_offline %>
138 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
139 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
140 map.addLayer(map.dataLayer);
142 map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
143 serverURL : "/api/0.6/",
144 iconOpen : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
145 iconClosed : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
148 cookieLifetime : 1000,
149 cookiePath : "/my/map/",
150 permalinkURL : "http://www.openstreetmap.org/",
151 theme : "http://osm.cdauth.de/map/openstreetbugs.css"
154 map.addLayer(map.osbLayer);
156 map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
157 map.addControl(map.osbControl);
159 var lBug = document.getElementById('ReportBug');
160 lBug.addEventListener('click',function (e) {
161 map.osbControl.activate(); document.getElementById("map_OpenLayers_Container").style.cursor = "crosshair"; if (e.stopPropagation) e.stopPropagation(); },false);
166 <% unless object_zoom %>
168 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
173 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
174 Event.observe(window, 'load', function() { addBoxToMap(bbox) });
177 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
178 var zoom = <%= zoom %>;
180 <% if params['scale'] and params['scale'].length > 0 then %>
181 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
184 setMapCenter(centre, zoom);
190 <% if !layers.nil? and !layers.empty? %>
191 setMapLayers("<%= layers %>");
195 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
199 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
201 <% if object_type != "node" %>
205 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
206 Event.observe(window, 'load', function() { addObjectToMap(url, <%= object_zoom %>) });
209 map.events.register("moveend", map, updateLocation);
210 map.events.register("changelayer", map, updateLocation);
215 function toggleData() {
216 if (map.dataLayer.visibility) {
217 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
218 } else if (map.dataLayer.active) {
223 function getPosition() {
224 return getMapCenter();
231 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
232 var centre = new OpenLayers.LonLat(lon, lat);
234 if (min_lon && min_lat && max_lon && max_lat) {
235 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
239 setMapCenter(centre, zoom);
243 removeMarkerFromMap(marker);
245 marker = addMarkerToMap(centre, getArrowIcon());
248 function updateLocation() {
249 var lonlat = getMapCenter();
250 var zoom = map.getZoom();
251 var layers = getMapLayers();
252 var extents = getMapExtent();
253 var expiry = new Date();
258 objtype = "<%= object_type %>";
259 objid = <%= object_id %>;
262 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
264 expiry.setYear(expiry.getFullYear() + 10);
265 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
268 function resizeContent() {
269 var content = $("content");
270 var rightMargin = parseInt(getStyle(content, "right"));
271 var bottomMargin = parseInt(getStyle(content, "bottom"));
273 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
274 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
277 function resizeMap() {
278 var centre = map.getCenter();
279 var zoom = map.getZoom();
280 var sidebar_width = $("sidebar").offsetWidth;
282 if (sidebar_width > 0) {
283 sidebar_width = sidebar_width + 5
286 $("map").style.left = (sidebar_width) + "px";
287 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
288 $("map").style.height = ($("content").offsetHeight - 2) + "px";
290 map.setCenter(centre, zoom);
293 function handleResize() {
294 if (brokenContentSize) {
303 window.onload = handleResize;
304 window.onresize = handleResize;
306 <% if params['action'] == 'export' %>
307 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>