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' %>
12 <div id="datalink"><%= link_to_remote 'See Data', {:url => {:controller => 'browse', :action => 'start'}}, {:href => url_for( {:controller => 'browse', :action => 'index'}), :id => 'browseanchor', :title => 'browse data'} %></div>
13 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
16 <div id="attribution">
19 <td align="left">http://creativecommons.org/licenses/by-sa/2.0/</td>
20 <td align="right">http://openstreetmap.org/</td>
23 <td colspan="2" align="center">
24 Licensed under the Creative Commons Attribution-Share Alike 2.0 license
25 by the OpenStreetMap project and it's contributors.
30 <% if params['mlon'] and params['mlat'] %>
32 <% mlon = h(params['mlon']) %>
33 <% mlat = h(params['mlat']) %>
36 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
38 <% minlon = h(params['minlon']) %>
39 <% minlat = h(params['minlat']) %>
40 <% maxlon = h(params['maxlon']) %>
41 <% maxlat = h(params['maxlat']) %>
44 <% if params['lon'] and params['lat'] %>
45 <% lon = h(params['lon']) %>
46 <% lat = h(params['lat']) %>
47 <% zoom = h(params['zoom'] || '5') %>
48 <% layers = h(params['layers']) %>
49 <% elsif params['mlon'] and params['mlat'] %>
50 <% lon = h(params['mlon']) %>
51 <% lat = h(params['mlat']) %>
52 <% zoom = h(params['zoom'] || '12') %>
53 <% layers = h(params['layers']) %>
54 <% elsif cookies.key?("location") %>
55 <% lon,lat,zoom,layers = cookies["location"].split(",") %>
56 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
57 <% lon = @user.home_lon %>
58 <% lat = @user.home_lat %>
61 <% session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location] %>
62 <% if session[:location] %>
64 <% minlon = session[:location][:minlon] %>
65 <% minlat = session[:location][:minlat] %>
66 <% maxlon = session[:location][:maxlon] %>
67 <% maxlat = session[:location][:maxlat] %>
71 <% zoom = h(params['zoom'] || '5') %>
72 <% layers = h(params['layers']) %>
76 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
77 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
78 <%= javascript_include_tag 'map.js' %>
81 <script type="text/javascript" defer="defer">
83 var brokenContentSize = $("content").offsetWidth == 0;
88 map = createMap("map");
91 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
95 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
96 var zoom = <%= zoom %>;
98 <% if params['scale'] and params['scale'].length > 0 then %>
99 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
102 setMapCenter(centre, zoom);
106 setMapLayers("<%= layers %>");
110 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
113 map.events.register("zoomend", map, updateKey);
115 map.events.register("moveend", map, updateLocation);
116 map.events.register("changelayer", map, updateLocation);
122 function getPosition() {
123 return getMapCenter();
126 function setPosition(lat, lon, zoom) {
127 var centre = new OpenLayers.LonLat(lon, lat);
129 setMapCenter(centre, zoom);
132 removeMarkerFromMap(marker);
134 marker = addMarkerToMap(centre, getArrowIcon());
137 function updateLocation() {
138 var lonlat = getMapCenter();
139 var zoom = map.getZoom();
140 var layers = getMapLayers();
142 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
144 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
147 function resizeContent() {
148 var content = $("content");
149 var rightMargin = parseInt(getStyle(content, "right"));
150 var bottomMargin = parseInt(getStyle(content, "bottom"));
152 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
153 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
156 function resizeMap() {
157 var centre = map.getCenter();
158 var zoom = map.getZoom();
159 var sidebar_width = $("sidebar").offsetWidth;
161 if (sidebar_width > 0) {
162 sidebar_width = sidebar_width + 5
165 $("map").style.left = (sidebar_width) + "px";
166 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
167 $("map").style.height = ($("content").offsetHeight - 2) + "px";
169 map.setCenter(centre, zoom);
172 function handleResize() {
173 if (brokenContentSize) {
182 window.onload = handleResize;
183 window.onresize = handleResize;
185 <% if params['action'] == 'export' %>
186 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>