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");
98 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
102 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
103 var zoom = <%= zoom %>;
105 <% if params['scale'] and params['scale'].length > 0 then %>
106 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
109 setMapCenter(centre, zoom);
112 <% if !layers.empty? %>
113 setMapLayers("<%= layers %>");
117 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
120 map.events.register("zoomend", map, updateKey);
122 map.events.register("moveend", map, updateLocation);
123 map.events.register("changelayer", map, updateLocation);
129 function getPosition() {
130 return getMapCenter();
133 function setPosition(lat, lon, zoom) {
134 var centre = new OpenLayers.LonLat(lon, lat);
136 setMapCenter(centre, zoom);
139 removeMarkerFromMap(marker);
141 marker = addMarkerToMap(centre, getArrowIcon());
144 function updateLocation() {
145 var lonlat = getMapCenter();
146 var zoom = map.getZoom();
147 var layers = getMapLayers();
149 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
151 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
154 function resizeContent() {
155 var content = $("content");
156 var rightMargin = parseInt(getStyle(content, "right"));
157 var bottomMargin = parseInt(getStyle(content, "bottom"));
159 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
160 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
163 function resizeMap() {
164 var centre = map.getCenter();
165 var zoom = map.getZoom();
166 var sidebar_width = $("sidebar").offsetWidth;
168 if (sidebar_width > 0) {
169 sidebar_width = sidebar_width + 5
172 $("map").style.left = (sidebar_width) + "px";
173 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
174 $("map").style.height = ($("content").offsetHeight - 2) + "px";
176 map.setCenter(centre, zoom);
179 function handleResize() {
180 if (brokenContentSize) {
189 window.onload = handleResize;
190 window.onresize = handleResize;
192 <% if params['action'] == 'export' %>
193 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>