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><%= t 'site.index.js_1' %></p>
14 <p><%= t 'site.index.js_2' %></p>
15 <p><%= t 'site.index.js_3' %></p>
20 <div id="permalink"><a href="/" id="permalinkanchor"><%= t 'site.index.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"><%= t 'site.index.license' %></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();
173 var expiry = new Date();
175 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top);
177 expiry.setYear(expiry.getFullYear() + 10);
178 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
181 function resizeContent() {
182 var content = $("content");
183 var rightMargin = parseInt(getStyle(content, "right"));
184 var bottomMargin = parseInt(getStyle(content, "bottom"));
186 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
187 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
190 function resizeMap() {
191 var centre = map.getCenter();
192 var zoom = map.getZoom();
193 var sidebar_width = $("sidebar").offsetWidth;
195 if (sidebar_width > 0) {
196 sidebar_width = sidebar_width + 5
199 $("map").style.left = (sidebar_width) + "px";
200 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
201 $("map").style.height = ($("content").offsetHeight - 2) + "px";
203 map.setCenter(centre, zoom);
206 function handleResize() {
207 if (brokenContentSize) {
216 window.onload = handleResize;
217 window.onresize = handleResize;
219 <% if params['action'] == 'export' %>
220 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>