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 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
115 Event.observe(window, 'load', function() {addBoxToMap(bbox)});
118 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
119 var zoom = <%= zoom %>;
121 <% if params['scale'] and params['scale'].length > 0 then %>
122 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
125 setMapCenter(centre, zoom);
128 <% if !layers.nil? and !layers.empty? %>
129 setMapLayers("<%= layers %>");
133 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
136 map.events.register("zoomend", map, updateKey);
138 map.events.register("moveend", map, updateLocation);
139 map.events.register("changelayer", map, updateLocation);
145 function toggleData() {
146 if (map.dataLayer.visibility) {
147 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
153 function getPosition() {
154 return getMapCenter();
157 function setPosition(lat, lon, zoom) {
158 var centre = new OpenLayers.LonLat(lon, lat);
160 setMapCenter(centre, zoom);
163 removeMarkerFromMap(marker);
165 marker = addMarkerToMap(centre, getArrowIcon());
168 function updateLocation() {
169 var lonlat = getMapCenter();
170 var zoom = map.getZoom();
171 var layers = getMapLayers();
172 var extents = getMapExtent();
174 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents);
176 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers;
179 function resizeContent() {
180 var content = $("content");
181 var rightMargin = parseInt(getStyle(content, "right"));
182 var bottomMargin = parseInt(getStyle(content, "bottom"));
184 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
185 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
188 function resizeMap() {
189 var centre = map.getCenter();
190 var zoom = map.getZoom();
191 var sidebar_width = $("sidebar").offsetWidth;
193 if (sidebar_width > 0) {
194 sidebar_width = sidebar_width + 5
197 $("map").style.left = (sidebar_width) + "px";
198 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
199 $("map").style.height = ($("content").offsetHeight - 2) + "px";
201 map.setCenter(centre, zoom);
204 function handleResize() {
205 if (brokenContentSize) {
214 window.onload = handleResize;
215 window.onresize = handleResize;
217 <% if params['action'] == 'export' %>
218 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>