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="center"><%=
27 I18n.t('site.index.license.notice',
28 :license_name => ('<a href="' + t('site.index.license.license_url') + '">' + t('site.index.license.license_name') + '</a>'),
29 :project_name => ('<a href="' + t('site.index.license.project_url') + '">' + t('site.index.license.project_name') + '</a>'))
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;
100 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
103 map = createMap("map");
105 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
106 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
107 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
108 map.addLayer(map.dataLayer);
112 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
116 // IE requires Vector layers be initialised on page load, and not under deferred script conditions
117 Event.observe(window, 'load', function() {addBoxToMap(bbox)});
120 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
121 var zoom = <%= zoom %>;
123 <% if params['scale'] and params['scale'].length > 0 then %>
124 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
127 setMapCenter(centre, zoom);
130 <% if !layers.nil? and !layers.empty? %>
131 setMapLayers("<%= layers %>");
135 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
138 map.events.register("zoomend", map, updateKey);
140 map.events.register("moveend", map, updateLocation);
141 map.events.register("changelayer", map, updateLocation);
147 function toggleData() {
148 if (map.dataLayer.visibility) {
149 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
155 function getPosition() {
156 return getMapCenter();
159 function setPosition(lat, lon, zoom) {
160 var centre = new OpenLayers.LonLat(lon, lat);
162 setMapCenter(centre, zoom);
165 removeMarkerFromMap(marker);
167 marker = addMarkerToMap(centre, getArrowIcon());
170 function updateLocation() {
171 var lonlat = getMapCenter();
172 var zoom = map.getZoom();
173 var layers = getMapLayers();
174 var extents = getMapExtent();
175 var expiry = new Date();
177 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top);
179 expiry.setYear(expiry.getFullYear() + 10);
180 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers + "; expires=" + expiry.toGMTString();
183 function resizeContent() {
184 var content = $("content");
185 var rightMargin = parseInt(getStyle(content, "right"));
186 var bottomMargin = parseInt(getStyle(content, "bottom"));
188 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
189 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
192 function resizeMap() {
193 var centre = map.getCenter();
194 var zoom = map.getZoom();
195 var sidebar_width = $("sidebar").offsetWidth;
197 if (sidebar_width > 0) {
198 sidebar_width = sidebar_width + 5
201 $("map").style.left = (sidebar_width) + "px";
202 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
203 $("map").style.height = ($("content").offsetHeight - 2) + "px";
205 map.setCenter(centre, zoom);
208 function handleResize() {
209 if (brokenContentSize) {
218 window.onload = handleResize;
219 window.onresize = handleResize;
221 <% if params['action'] == 'export' %>
222 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>