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="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
15 <div id="attribution">
18 <td align="left">http://creativecommons.org/licenses/by-sa/2.0/</td>
19 <td align="right">http://openstreetmap.org/</td>
22 <td colspan="2" align="center">
23 Licensed under the Creative Commons Attribution-Share Alike 2.0 license
24 by the OpenStreetMap project and its contributors.
29 <% if params['mlon'] and params['mlat'] %>
31 <% mlon = h(params['mlon']) %>
32 <% mlat = h(params['mlat']) %>
35 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
37 <% minlon = h(params['minlon']) %>
38 <% minlat = h(params['minlat']) %>
39 <% maxlon = h(params['maxlon']) %>
40 <% maxlat = h(params['maxlat']) %>
43 <% if params['lon'] and params['lat'] %>
44 <% lon = h(params['lon']) %>
45 <% lat = h(params['lat']) %>
46 <% zoom = h(params['zoom'] || '5') %>
47 <% layers = h(params['layers']) %>
48 <% elsif params['mlon'] and params['mlat'] %>
49 <% lon = h(params['mlon']) %>
50 <% lat = h(params['mlat']) %>
51 <% zoom = h(params['zoom'] || '12') %>
52 <% layers = h(params['layers']) %>
53 <% elsif cookies.key?("location") %>
54 <% lon,lat,zoom,layers = cookies["location"].split(",") %>
55 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
56 <% lon = @user.home_lon %>
57 <% lat = @user.home_lat %>
60 <% session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location] %>
61 <% if session[:location] %>
63 <% minlon = session[:location][:minlon] %>
64 <% minlat = session[:location][:minlat] %>
65 <% maxlon = session[:location][:maxlon] %>
66 <% maxlat = session[:location][:maxlat] %>
70 <% zoom = h(params['zoom'] || '5') %>
71 <% layers = h(params['layers']) %>
75 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
76 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
77 <%= javascript_include_tag 'map.js' %>
80 <script type="text/javascript" defer="defer">
82 var brokenContentSize = $("content").offsetWidth == 0;
87 map = createMap("map");
89 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
90 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
91 map.addLayer(map.dataLayer);
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 toggleData() {
126 if (map.dataLayer.visibility) {
127 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
133 function getPosition() {
134 return getMapCenter();
137 function setPosition(lat, lon, zoom) {
138 var centre = new OpenLayers.LonLat(lon, lat);
140 setMapCenter(centre, zoom);
143 removeMarkerFromMap(marker);
145 marker = addMarkerToMap(centre, getArrowIcon());
148 function updateLocation() {
149 var lonlat = getMapCenter();
150 var zoom = map.getZoom();
151 var layers = getMapLayers();
153 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
155 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
158 function resizeContent() {
159 var content = $("content");
160 var rightMargin = parseInt(getStyle(content, "right"));
161 var bottomMargin = parseInt(getStyle(content, "bottom"));
163 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
164 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
167 function resizeMap() {
168 var centre = map.getCenter();
169 var zoom = map.getZoom();
170 var sidebar_width = $("sidebar").offsetWidth;
172 if (sidebar_width > 0) {
173 sidebar_width = sidebar_width + 5
176 $("map").style.left = (sidebar_width) + "px";
177 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
178 $("map").style.height = ($("content").offsetHeight - 2) + "px";
180 map.setCenter(centre, zoom);
183 function handleResize() {
184 if (brokenContentSize) {
193 window.onload = handleResize;
194 window.onresize = handleResize;
196 <% if params['action'] == 'export' %>
197 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>