1 <% content_for :greeting do %>
2 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
3 <%= link_to_function t('layouts.home'), "setPosition(#{@user.home_lat}, #{@user.home_lon}, 10)", { :title => t('layouts.home_tooltip') } %> |
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"><%= t'site.index.license.license_url' %></td>
27 <td align="right"><%= t'site.index.license.project_url' %></td>
30 <td colspan="2" align="center"><%=
31 t'site.index.license.notice',
32 :license_name => t('site.index.license.license_name'),
33 :project_name => t('site.index.license.project_name')
40 if params['mlon'] and params['mlat']
42 mlon = h(params['mlon'])
43 mlat = h(params['mlat'])
46 if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat']
48 minlon = h(params['minlon'])
49 minlat = h(params['minlat'])
50 maxlon = h(params['maxlon'])
51 maxlat = h(params['maxlat'])
52 box = true if params['box']=="yes"
55 # Decide on a lat lon to initialise the map with. Various ways of doing this
56 if params['lon'] and params['lat']
57 lon = h(params['lon'])
58 lat = h(params['lat'])
59 zoom = h(params['zoom'] || '5')
60 layers = h(params['layers'])
62 elsif params['mlon'] and params['mlat']
63 lon = h(params['mlon'])
64 lat = h(params['mlat'])
65 zoom = h(params['zoom'] || '12')
66 layers = h(params['layers'])
68 elsif cookies.key?("_osm_location")
69 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
71 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
76 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
80 minlon = session[:location][:minlon]
81 minlat = session[:location][:minlat]
82 maxlon = session[:location][:maxlon]
83 maxlat = session[:location][:maxlat]
87 zoom = h(params['zoom'] || '5')
89 layers = h(params['layers'])
93 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
94 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
95 <%= javascript_include_tag 'map.js' %>
98 <script type="text/javascript" defer="defer">
100 var brokenContentSize = $("content").offsetWidth == 0;
104 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
107 map = createMap("map");
109 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
110 map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
111 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
112 map.addLayer(map.dataLayer);
116 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
120 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
121 Event.observe(window, 'load', function() {addBoxToMap(bbox)});
124 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
125 var zoom = <%= zoom %>;
127 <% if params['scale'] and params['scale'].length > 0 then %>
128 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
131 setMapCenter(centre, zoom);
134 <% if !layers.nil? and !layers.empty? %>
135 setMapLayers("<%= layers %>");
139 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
142 map.events.register("zoomend", map, updateKey);
144 map.events.register("moveend", map, updateLocation);
145 map.events.register("changelayer", map, updateLocation);
151 function toggleData() {
152 if (map.dataLayer.visibility) {
153 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
159 function getPosition() {
160 return getMapCenter();
163 function setPosition(lat, lon, zoom) {
164 var centre = new OpenLayers.LonLat(lon, lat);
166 setMapCenter(centre, zoom);
169 removeMarkerFromMap(marker);
171 marker = addMarkerToMap(centre, getArrowIcon());
174 function updateLocation() {
175 var lonlat = getMapCenter();
176 var zoom = map.getZoom();
177 var layers = getMapLayers();
178 var extents = getMapExtent();
179 var expiry = new Date();
181 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top);
183 expiry.setYear(expiry.getFullYear() + 10);
184 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
187 function resizeContent() {
188 var content = $("content");
189 var rightMargin = parseInt(getStyle(content, "right"));
190 var bottomMargin = parseInt(getStyle(content, "bottom"));
192 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
193 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
196 function resizeMap() {
197 var centre = map.getCenter();
198 var zoom = map.getZoom();
199 var sidebar_width = $("sidebar").offsetWidth;
201 if (sidebar_width > 0) {
202 sidebar_width = sidebar_width + 5
205 $("map").style.left = (sidebar_width) + "px";
206 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
207 $("map").style.height = ($("content").offsetHeight - 2) + "px";
209 map.setCenter(centre, zoom);
212 function handleResize() {
213 if (brokenContentSize) {
222 window.onload = handleResize;
223 window.onresize = handleResize;
225 <% if params['action'] == 'export' %>
226 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>