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">Licensed under the Creative Commons Attribution-Share Alike 2.0 license by the OpenStreetMap project and its contributors.</td>
35 <% if params['mlon'] and params['mlat'] %>
37 <% mlon = h(params['mlon']) %>
38 <% mlat = h(params['mlat']) %>
41 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
43 <% minlon = h(params['minlon']) %>
44 <% minlat = h(params['minlat']) %>
45 <% maxlon = h(params['maxlon']) %>
46 <% maxlat = h(params['maxlat']) %>
49 <% if params['lon'] and params['lat'] %>
50 <% lon = h(params['lon']) %>
51 <% lat = h(params['lat']) %>
52 <% zoom = h(params['zoom'] || '5') %>
53 <% layers = h(params['layers']) %>
54 <% elsif params['mlon'] and params['mlat'] %>
55 <% lon = h(params['mlon']) %>
56 <% lat = h(params['mlat']) %>
57 <% zoom = h(params['zoom'] || '12') %>
58 <% layers = h(params['layers']) %>
59 <% elsif cookies.key?("_osm_location") %>
60 <% lon,lat,zoom,layers = cookies["_osm_location"].split("|") %>
61 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
62 <% lon = @user.home_lon %>
63 <% lat = @user.home_lat %>
66 <% session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location] %>
67 <% if session[:location] %>
69 <% minlon = session[:location][:minlon] %>
70 <% minlat = session[:location][:minlat] %>
71 <% maxlon = session[:location][:maxlon] %>
72 <% maxlat = session[:location][:maxlat] %>
76 <% zoom = h(params['zoom'] || '5') %>
78 <% layers = h(params['layers']) %>
81 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
82 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
83 <%= javascript_include_tag 'map.js' %>
86 <script type="text/javascript" defer="defer">
88 var brokenContentSize = $("content").offsetWidth == 0;
93 map = createMap("map");
95 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
96 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
97 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
98 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);
116 <% if !layers.nil? and !layers.empty? %>
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 = "_osm_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' } %>