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("moveend", map, updateLocation);
143 map.events.register("changelayer", map, updateLocation);
149 function toggleData() {
150 if (map.dataLayer.visibility) {
151 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
157 function getPosition() {
158 return getMapCenter();
161 function setPosition(lat, lon, zoom) {
162 var centre = new OpenLayers.LonLat(lon, lat);
164 setMapCenter(centre, zoom);
167 removeMarkerFromMap(marker);
169 marker = addMarkerToMap(centre, getArrowIcon());
172 function updateLocation() {
173 var lonlat = getMapCenter();
174 var zoom = map.getZoom();
175 var layers = getMapLayers();
176 var extents = getMapExtent();
177 var expiry = new Date();
179 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top);
181 expiry.setYear(expiry.getFullYear() + 10);
182 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
185 function resizeContent() {
186 var content = $("content");
187 var rightMargin = parseInt(getStyle(content, "right"));
188 var bottomMargin = parseInt(getStyle(content, "bottom"));
190 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
191 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
194 function resizeMap() {
195 var centre = map.getCenter();
196 var zoom = map.getZoom();
197 var sidebar_width = $("sidebar").offsetWidth;
199 if (sidebar_width > 0) {
200 sidebar_width = sidebar_width + 5
203 $("map").style.left = (sidebar_width) + "px";
204 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
205 $("map").style.height = ($("content").offsetHeight - 2) + "px";
207 map.setCenter(centre, zoom);
210 function handleResize() {
211 if (brokenContentSize) {
220 window.onload = handleResize;
221 window.onresize = handleResize;
223 <% if params['action'] == 'export' %>
224 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>