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><br/>
25 <a href="/" id="ReportBug">Report a problem</a>
28 <div id="attribution">
31 <td align="left"><%= t'site.index.license.license_url' %></td>
32 <td align="right"><%= t'site.index.license.project_url' %></td>
35 <td colspan="2" align="center"><%=
36 t'site.index.license.notice',
37 :license_name => t('site.index.license.license_name'),
38 :project_name => t('site.index.license.project_name')
45 if params['mlon'] and params['mlat']
47 mlon = h(params['mlon'])
48 mlat = h(params['mlat'])
51 if params['node'] or params['way'] or params['relation']
57 object_id = h(params['node'])
60 object_id = h(params['way'])
61 elsif params['relation']
62 object_type = 'relation'
63 object_id = h(params['relation'])
67 if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
69 minlon = h(params['minlon'])
70 minlat = h(params['minlat'])
71 maxlon = h(params['maxlon'])
72 maxlat = h(params['maxlat'])
73 box = true if params['box']=="yes"
77 # Decide on a lat lon to initialise the map with. Various ways of doing this
78 if params['lon'] and params['lat']
79 lon = h(params['lon'])
80 lat = h(params['lat'])
81 zoom = h(params['zoom'] || '5')
82 layers = h(params['layers'])
84 elsif params['mlon'] and params['mlat']
85 lon = h(params['mlon'])
86 lat = h(params['mlat'])
87 zoom = h(params['zoom'] || '12')
88 layers = h(params['layers'])
90 elsif cookies.key?("_osm_location")
91 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
92 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
97 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
101 minlon = session[:location][:minlon]
102 minlat = session[:location][:minlat]
103 maxlon = session[:location][:maxlon]
104 maxlat = session[:location][:maxlat]
108 zoom = h(params['zoom'] || '5')
111 layers = h(params['layers'])
115 <!--Use stock OpenLayers for now, as the OSM one is missing some needed classes-->
116 <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
117 <!-- < %= javascript_include_tag '/openlayers/OpenLayers.js' % > -->
118 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
119 <%= javascript_include_tag 'openstreetbugs.js' %>
120 <%= javascript_include_tag 'map.js' %>
122 <script type="text/javascript" defer="defer">
124 var brokenContentSize = $("content").offsetWidth == 0;
128 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
130 function createBugCallBack() {
131 map.osbControl.deactivate();
132 document.getElementById("map_OpenLayers_Container").style.cursor = "default";
136 map = createMap("map");
138 <% unless STATUS == :api_offline or STATUS == :database_offline %>
139 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
140 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
141 map.addLayer(map.dataLayer);
143 map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
144 serverURL : "/api/0.6/",
145 iconOpen : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
146 iconClosed : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
149 cookieLifetime : 1000,
150 cookiePath : "/my/map/",
151 permalinkURL : "http://www.openstreetmap.org/",
152 theme : "http://osm.cdauth.de/map/openstreetbugs.css"
155 map.addLayer(map.osbLayer);
157 map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
158 map.addControl(map.osbControl);
160 var lBug = document.getElementById('ReportBug');
161 lBug.addEventListener('click',function (e) {
162 map.osbControl.activate(); document.getElementById("map_OpenLayers_Container").style.cursor = "crosshair"; if (e.stopPropagation) e.stopPropagation(); },false);
167 <% unless object_zoom %>
169 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
174 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
175 Event.observe(window, 'load', function() { addBoxToMap(bbox) });
178 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
179 var zoom = <%= zoom %>;
181 <% if params['scale'] and params['scale'].length > 0 then %>
182 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
185 setMapCenter(centre, zoom);
191 <% if !layers.nil? and !layers.empty? %>
192 setMapLayers("<%= layers %>");
196 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
200 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
202 <% if object_type != "node" %>
206 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
207 Event.observe(window, 'load', function() { addObjectToMap(url, <%= object_zoom %>) });
210 map.events.register("moveend", map, updateLocation);
211 map.events.register("changelayer", map, updateLocation);
216 function toggleData() {
217 if (map.dataLayer.visibility) {
218 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
219 } else if (map.dataLayer.active) {
224 function getPosition() {
225 return getMapCenter();
232 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
233 var centre = new OpenLayers.LonLat(lon, lat);
235 if (min_lon && min_lat && max_lon && max_lat) {
236 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
240 setMapCenter(centre, zoom);
244 removeMarkerFromMap(marker);
246 marker = addMarkerToMap(centre, getArrowIcon());
249 function updateLocation() {
250 var lonlat = getMapCenter();
251 var zoom = map.getZoom();
252 var layers = getMapLayers();
253 var extents = getMapExtent();
254 var expiry = new Date();
259 objtype = "<%= object_type %>";
260 objid = <%= object_id %>;
263 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
265 expiry.setYear(expiry.getFullYear() + 10);
266 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
269 function resizeContent() {
270 var content = $("content");
271 var rightMargin = parseInt(getStyle(content, "right"));
272 var bottomMargin = parseInt(getStyle(content, "bottom"));
274 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
275 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
278 function resizeMap() {
279 var centre = map.getCenter();
280 var zoom = map.getZoom();
281 var sidebar_width = $("sidebar").offsetWidth;
283 if (sidebar_width > 0) {
284 sidebar_width = sidebar_width + 5
287 $("map").style.left = (sidebar_width) + "px";
288 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
289 $("map").style.height = ($("content").offsetHeight - 2) + "px";
291 map.setCenter(centre, zoom);
294 function handleResize() {
295 if (brokenContentSize) {
304 window.onload = handleResize;
305 window.onresize = handleResize;
307 <% if params['action'] == 'export' %>
308 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>