1 <% content_for :greeting do %>
2 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
3 <%= link_to_function 'home', "setPosition(#{@user.home_lat}, #{@user.home_lon}, 10)" %> |
7 <%= render :partial => 'sidebar', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
8 <%= render :partial => 'key' %>
9 <%= render :partial => 'search' %>
11 <noscript><div id="noscript"><p>You are either using a browser that doesn't support javascript, or you have disabled javascript.</p>
12 <p>OpenStreetMap uses javascript for its slippy map.</p>
13 <p>Try the <a href="http://tah.openstreetmap.org/Browse/">OpenStreetMap static tile browser</a>.</p></div></noscript>
16 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
19 <div id="attribution">
22 <td align="left">http://creativecommons.org/licenses/by-sa/2.0/</td>
23 <td align="right">http://openstreetmap.org/</td>
26 <td colspan="2" align="center">
27 Licensed under the Creative Commons Attribution-Share Alike 2.0 license
28 by the OpenStreetMap project and its contributors.
33 <% if params['mlon'] and params['mlat'] %>
35 <% mlon = h(params['mlon']) %>
36 <% mlat = h(params['mlat']) %>
39 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
41 <% minlon = h(params['minlon']) %>
42 <% minlat = h(params['minlat']) %>
43 <% maxlon = h(params['maxlon']) %>
44 <% maxlat = h(params['maxlat']) %>
47 <% if params['lon'] and params['lat'] %>
48 <% lon = h(params['lon']) %>
49 <% lat = h(params['lat']) %>
50 <% zoom = h(params['zoom'] || '5') %>
51 <% layers = h(params['layers']) %>
52 <% elsif params['mlon'] and params['mlat'] %>
53 <% lon = h(params['mlon']) %>
54 <% lat = h(params['mlat']) %>
55 <% zoom = h(params['zoom'] || '12') %>
56 <% layers = h(params['layers']) %>
57 <% elsif cookies.key?("location") %>
58 <% lon,lat,zoom,layers = cookies["location"].split(",") %>
59 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
60 <% lon = @user.home_lon %>
61 <% lat = @user.home_lat %>
64 <% session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location] %>
65 <% if session[:location] %>
67 <% minlon = session[:location][:minlon] %>
68 <% minlat = session[:location][:minlat] %>
69 <% maxlon = session[:location][:maxlon] %>
70 <% maxlat = session[:location][:maxlat] %>
74 <% zoom = h(params['zoom'] || '5') %>
75 <% layers = h(params['layers']) %>
79 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
80 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
81 <%= javascript_include_tag 'map.js' %>
84 <script type="text/javascript" defer="defer">
86 var brokenContentSize = $("content").offsetWidth == 0;
91 map = createMap("map");
94 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
98 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
99 var zoom = <%= zoom %>;
101 <% if params['scale'] and params['scale'].length > 0 then %>
102 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
105 setMapCenter(centre, zoom);
109 setMapLayers("<%= layers %>");
113 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
116 map.events.register("zoomend", map, updateKey);
118 map.events.register("moveend", map, updateLocation);
119 map.events.register("changelayer", map, updateLocation);
125 function getPosition() {
126 return getMapCenter();
129 function setPosition(lat, lon, zoom) {
130 var centre = new OpenLayers.LonLat(lon, lat);
132 setMapCenter(centre, zoom);
135 removeMarkerFromMap(marker);
137 marker = addMarkerToMap(centre, getArrowIcon());
140 function updateLocation() {
141 var lonlat = getMapCenter();
142 var zoom = map.getZoom();
143 var layers = getMapLayers();
145 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
147 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
150 function resizeContent() {
151 var content = $("content");
152 var rightMargin = parseInt(getStyle(content, "right"));
153 var bottomMargin = parseInt(getStyle(content, "bottom"));
155 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
156 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
159 function resizeMap() {
160 var centre = map.getCenter();
161 var zoom = map.getZoom();
162 var sidebar_width = $("sidebar").offsetWidth;
164 if (sidebar_width > 0) {
165 sidebar_width = sidebar_width + 5
168 $("map").style.left = (sidebar_width) + "px";
169 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
170 $("map").style.height = ($("content").offsetHeight - 2) + "px";
172 map.setCenter(centre, zoom);
175 function handleResize() {
176 if (brokenContentSize) {
185 window.onload = handleResize;
186 window.onresize = handleResize;
188 <% if params['action'] == 'export' %>
189 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>