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 %>");
130 map = createMap("map");
132 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
133 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
134 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
135 map.addLayer(map.dataLayer);
137 map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
138 serverURL : "/api/0.6/bugs/",
139 iconOpen : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
140 iconClosed : new OpenLayers.Icon("http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
143 cookieLifetime : 1000,
144 cookiePath : "/my/map/",
145 permalinkURL : "http://www.openstreetmap.org/",
146 theme : "http://osm.cdauth.de/map/openstreetbugs.css"
149 map.addLayer(map.osbLayer);
151 map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
152 map.addControl(map.osbControl);
154 var lBug = document.getElementById('ReportBug');
155 lBug.addEventListener('click',function (e) {
156 map.osbControl.activate(); document.getElementById("map_OpenLayers_Container").style.cursor = "crosshair"; if (e.stopPropagation) e.stopPropagation(); },false);
161 <% unless object_zoom %>
163 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
168 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
169 Event.observe(window, 'load', function() { addBoxToMap(bbox) });
172 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
173 var zoom = <%= zoom %>;
175 <% if params['scale'] and params['scale'].length > 0 then %>
176 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
179 setMapCenter(centre, zoom);
185 <% if !layers.nil? and !layers.empty? %>
186 setMapLayers("<%= layers %>");
190 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
194 var url = "/api/<%= "#{API_VERSION}" %>/<%= object_type %>/<%= object_id %>";
196 <% if object_type != "node" %>
200 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
201 Event.observe(window, 'load', function() { addObjectToMap(url, <%= object_zoom %>) });
204 map.events.register("moveend", map, updateLocation);
205 map.events.register("changelayer", map, updateLocation);
210 function toggleData() {
211 if (map.dataLayer.visibility) {
212 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
213 } else if (map.dataLayer.active) {
218 function getPosition() {
219 return getMapCenter();
226 function setPosition(lat, lon, zoom, min_lon, min_lat, max_lon, max_lat) {
227 var centre = new OpenLayers.LonLat(lon, lat);
229 if (min_lon && min_lat && max_lon && max_lat) {
230 var bbox = new OpenLayers.Bounds(min_lon, min_lat, max_lon, max_lat);
234 setMapCenter(centre, zoom);
238 removeMarkerFromMap(marker);
240 marker = addMarkerToMap(centre, getArrowIcon());
243 function updateLocation() {
244 var lonlat = getMapCenter();
245 var zoom = map.getZoom();
246 var layers = getMapLayers();
247 var extents = getMapExtent();
248 var expiry = new Date();
253 objtype = "<%= object_type %>";
254 objid = <%= object_id %>;
257 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, objtype, objid);
259 expiry.setYear(expiry.getFullYear() + 10);
260 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
263 function resizeContent() {
264 var content = $("content");
265 var rightMargin = parseInt(getStyle(content, "right"));
266 var bottomMargin = parseInt(getStyle(content, "bottom"));
268 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
269 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
272 function resizeMap() {
273 var centre = map.getCenter();
274 var zoom = map.getZoom();
275 var sidebar_width = $("sidebar").offsetWidth;
277 if (sidebar_width > 0) {
278 sidebar_width = sidebar_width + 5
281 $("map").style.left = (sidebar_width) + "px";
282 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
283 $("map").style.height = ($("content").offsetHeight - 2) + "px";
285 map.setCenter(centre, zoom);
288 function handleResize() {
289 if (brokenContentSize) {
298 window.onload = handleResize;
299 window.onresize = handleResize;
301 <% if params['action'] == 'export' %>
302 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>