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' %>
13 <p>You are either using a browser that doesn't support javascript, or you have disabled javascript.</p>
14 <p>OpenStreetMap uses javascript for its slippy map.</p>
15 <p>You may want to try the <a href="http://tah.openstreetmap.org/Browse/">Tiles@Home static tile browser</a> if you are unable to enable javascript.</p>
20 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
23 <div id="attribution">
26 <td align="left">http://creativecommons.org/licenses/by-sa/2.0/</td>
27 <td align="right">http://openstreetmap.org/</td>
30 <td colspan="2" align="center">
31 Licensed under the Creative Commons Attribution-Share Alike 2.0 license
32 by the OpenStreetMap project and its contributors.
37 <% if params['mlon'] and params['mlat'] %>
39 <% mlon = h(params['mlon']) %>
40 <% mlat = h(params['mlat']) %>
43 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
45 <% minlon = h(params['minlon']) %>
46 <% minlat = h(params['minlat']) %>
47 <% maxlon = h(params['maxlon']) %>
48 <% maxlat = h(params['maxlat']) %>
51 <% if params['lon'] and params['lat'] %>
52 <% lon = h(params['lon']) %>
53 <% lat = h(params['lat']) %>
54 <% zoom = h(params['zoom'] || '5') %>
55 <% layers = h(params['layers']) %>
56 <% elsif params['mlon'] and params['mlat'] %>
57 <% lon = h(params['mlon']) %>
58 <% lat = h(params['mlat']) %>
59 <% zoom = h(params['zoom'] || '12') %>
60 <% layers = h(params['layers']) %>
61 <% elsif cookies.key?("location") %>
62 <% lon,lat,zoom,layers = cookies["location"].split(",") %>
63 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
64 <% lon = @user.home_lon %>
65 <% lat = @user.home_lat %>
68 <% session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location] %>
69 <% if session[:location] %>
71 <% minlon = session[:location][:minlon] %>
72 <% minlat = session[:location][:minlat] %>
73 <% maxlon = session[:location][:maxlon] %>
74 <% maxlat = session[:location][:maxlat] %>
78 <% zoom = h(params['zoom'] || '5') %>
79 <% layers = h(params['layers']) %>
83 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
84 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
85 <%= javascript_include_tag 'map.js' %>
88 <script type="text/javascript" defer="defer">
90 var brokenContentSize = $("content").offsetWidth == 0;
95 map = createMap("map");
97 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
98 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
99 map.addLayer(map.dataLayer);
102 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
106 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
107 var zoom = <%= zoom %>;
109 <% if params['scale'] and params['scale'].length > 0 then %>
110 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
113 setMapCenter(centre, zoom);
117 setMapLayers("<%= layers %>");
121 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
124 map.events.register("zoomend", map, updateKey);
126 map.events.register("moveend", map, updateLocation);
127 map.events.register("changelayer", map, updateLocation);
133 function toggleData() {
134 if (map.dataLayer.visibility) {
135 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
141 function getPosition() {
142 return getMapCenter();
145 function setPosition(lat, lon, zoom) {
146 var centre = new OpenLayers.LonLat(lon, lat);
148 setMapCenter(centre, zoom);
151 removeMarkerFromMap(marker);
153 marker = addMarkerToMap(centre, getArrowIcon());
156 function updateLocation() {
157 var lonlat = getMapCenter();
158 var zoom = map.getZoom();
159 var layers = getMapLayers();
161 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
163 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
166 function resizeContent() {
167 var content = $("content");
168 var rightMargin = parseInt(getStyle(content, "right"));
169 var bottomMargin = parseInt(getStyle(content, "bottom"));
171 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
172 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
175 function resizeMap() {
176 var centre = map.getCenter();
177 var zoom = map.getZoom();
178 var sidebar_width = $("sidebar").offsetWidth;
180 if (sidebar_width > 0) {
181 sidebar_width = sidebar_width + 5
184 $("map").style.left = (sidebar_width) + "px";
185 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
186 $("map").style.height = ($("content").offsetHeight - 2) + "px";
188 map.setCenter(centre, zoom);
191 function handleResize() {
192 if (brokenContentSize) {
201 window.onload = handleResize;
202 window.onresize = handleResize;
204 <% if params['action'] == 'export' %>
205 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>