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?("_osm_location") %>
62 <% lon,lat,zoom,layers = cookies["_osm_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') %>
80 <% 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 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
98 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
99 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
100 map.addLayer(map.dataLayer);
104 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
108 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
109 var zoom = <%= zoom %>;
111 <% if params['scale'] and params['scale'].length > 0 then %>
112 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
115 setMapCenter(centre, zoom);
118 <% if !layers.nil? and !layers.empty? %>
119 setMapLayers("<%= layers %>");
123 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
126 map.events.register("zoomend", map, updateKey);
128 map.events.register("moveend", map, updateLocation);
129 map.events.register("changelayer", map, updateLocation);
135 function toggleData() {
136 if (map.dataLayer.visibility) {
137 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
143 function getPosition() {
144 return getMapCenter();
147 function setPosition(lat, lon, zoom) {
148 var centre = new OpenLayers.LonLat(lon, lat);
150 setMapCenter(centre, zoom);
153 removeMarkerFromMap(marker);
155 marker = addMarkerToMap(centre, getArrowIcon());
158 function updateLocation() {
159 var lonlat = getMapCenter();
160 var zoom = map.getZoom();
161 var layers = getMapLayers();
163 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
165 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers;
168 function resizeContent() {
169 var content = $("content");
170 var rightMargin = parseInt(getStyle(content, "right"));
171 var bottomMargin = parseInt(getStyle(content, "bottom"));
173 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
174 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
177 function resizeMap() {
178 var centre = map.getCenter();
179 var zoom = map.getZoom();
180 var sidebar_width = $("sidebar").offsetWidth;
182 if (sidebar_width > 0) {
183 sidebar_width = sidebar_width + 5
186 $("map").style.left = (sidebar_width) + "px";
187 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
188 $("map").style.height = ($("content").offsetHeight - 2) + "px";
190 map.setCenter(centre, zoom);
193 function handleResize() {
194 if (brokenContentSize) {
203 window.onload = handleResize;
204 window.onresize = handleResize;
206 <% if params['action'] == 'export' %>
207 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>