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>
36 if params['mlon'] and params['mlat']
38 mlon = h(params['mlon'])
39 mlat = h(params['mlat'])
42 if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
44 minlon = h(params['minlon'])
45 minlat = h(params['minlat'])
46 maxlon = h(params['maxlon'])
47 maxlat = h(params['maxlat'])
48 box = true if params['box']=="yes"
51 # Decide on a lat lon to initialise the map with. Various ways of doing this
52 if params['lon'] and params['lat']
53 lon = h(params['lon'])
54 lat = h(params['lat'])
55 zoom = h(params['zoom'] || '5')
56 layers = h(params['layers'])
58 elsif params['mlon'] and params['mlat']
59 lon = h(params['mlon'])
60 lat = h(params['mlat'])
61 zoom = h(params['zoom'] || '12')
62 layers = h(params['layers'])
64 elsif cookies.key?("_osm_location")
65 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
67 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
72 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
76 minlon = session[:location][:minlon]
77 minlat = session[:location][:minlat]
78 maxlon = session[:location][:maxlon]
79 maxlat = session[:location][:maxlat]
83 zoom = h(params['zoom'] || '5')
85 layers = h(params['layers'])
89 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
90 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
91 <%= javascript_include_tag 'map.js' %>
94 <script type="text/javascript" defer="defer">
96 var brokenContentSize = $("content").offsetWidth == 0;
101 map = createMap("map");
103 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
104 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
105 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
106 map.addLayer(map.dataLayer);
110 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
114 box = addBoxToMap(bbox);
117 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
118 var zoom = <%= zoom %>;
120 <% if params['scale'] and params['scale'].length > 0 then %>
121 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
124 setMapCenter(centre, zoom);
127 <% if !layers.nil? and !layers.empty? %>
128 setMapLayers("<%= layers %>");
132 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
135 map.events.register("zoomend", map, updateKey);
137 map.events.register("moveend", map, updateLocation);
138 map.events.register("changelayer", map, updateLocation);
144 function toggleData() {
145 if (map.dataLayer.visibility) {
146 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
152 function getPosition() {
153 return getMapCenter();
156 function setPosition(lat, lon, zoom) {
157 var centre = new OpenLayers.LonLat(lon, lat);
159 setMapCenter(centre, zoom);
162 removeMarkerFromMap(marker);
164 marker = addMarkerToMap(centre, getArrowIcon());
167 function updateLocation() {
168 var lonlat = getMapCenter();
169 var zoom = map.getZoom();
170 var layers = getMapLayers();
171 var extents = getMapExtent();
173 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents);
175 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers;
178 function resizeContent() {
179 var content = $("content");
180 var rightMargin = parseInt(getStyle(content, "right"));
181 var bottomMargin = parseInt(getStyle(content, "bottom"));
183 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
184 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
187 function resizeMap() {
188 var centre = map.getCenter();
189 var zoom = map.getZoom();
190 var sidebar_width = $("sidebar").offsetWidth;
192 if (sidebar_width > 0) {
193 sidebar_width = sidebar_width + 5
196 $("map").style.left = (sidebar_width) + "px";
197 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
198 $("map").style.height = ($("content").offsetHeight - 2) + "px";
200 map.setCenter(centre, zoom);
203 function handleResize() {
204 if (brokenContentSize) {
213 window.onload = handleResize;
214 window.onresize = handleResize;
216 <% if params['action'] == 'export' %>
217 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>