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'])
50 # Decide on a lat lon to initialise the map with. Various ways of doing this
51 if params['lon'] and params['lat']
52 lon = h(params['lon'])
53 lat = h(params['lat'])
54 zoom = h(params['zoom'] || '5')
55 layers = h(params['layers'])
57 elsif params['mlon'] and params['mlat']
58 lon = h(params['mlon'])
59 lat = h(params['mlat'])
60 zoom = h(params['zoom'] || '12')
61 layers = h(params['layers'])
63 elsif cookies.key?("_osm_location")
64 lon,lat,zoom,layers = cookies["_osm_location"].split("|")
66 elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil?
71 session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location]
75 minlon = session[:location][:minlon]
76 minlat = session[:location][:minlat]
77 maxlon = session[:location][:maxlon]
78 maxlat = session[:location][:maxlat]
82 zoom = h(params['zoom'] || '5')
84 layers = h(params['layers'])
88 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
89 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
90 <%= javascript_include_tag 'map.js' %>
93 <script type="text/javascript" defer="defer">
95 var brokenContentSize = $("content").offsetWidth == 0;
100 map = createMap("map");
102 <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
103 map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
104 map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
105 map.addLayer(map.dataLayer);
109 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
113 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
114 var zoom = <%= zoom %>;
116 <% if params['scale'] and params['scale'].length > 0 then %>
117 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
120 setMapCenter(centre, zoom);
123 <% if !layers.nil? and !layers.empty? %>
124 setMapLayers("<%= layers %>");
128 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
131 map.events.register("zoomend", map, updateKey);
133 map.events.register("moveend", map, updateLocation);
134 map.events.register("changelayer", map, updateLocation);
140 function toggleData() {
141 if (map.dataLayer.visibility) {
142 <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
148 function getPosition() {
149 return getMapCenter();
152 function setPosition(lat, lon, zoom) {
153 var centre = new OpenLayers.LonLat(lon, lat);
155 setMapCenter(centre, zoom);
158 removeMarkerFromMap(marker);
160 marker = addMarkerToMap(centre, getArrowIcon());
163 function updateLocation() {
164 var lonlat = getMapCenter();
165 var zoom = map.getZoom();
166 var layers = getMapLayers();
167 var extents = getMapExtent();
169 updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents);
171 document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers;
174 function resizeContent() {
175 var content = $("content");
176 var rightMargin = parseInt(getStyle(content, "right"));
177 var bottomMargin = parseInt(getStyle(content, "bottom"));
179 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
180 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
183 function resizeMap() {
184 var centre = map.getCenter();
185 var zoom = map.getZoom();
186 var sidebar_width = $("sidebar").offsetWidth;
188 if (sidebar_width > 0) {
189 sidebar_width = sidebar_width + 5
192 $("map").style.left = (sidebar_width) + "px";
193 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
194 $("map").style.height = ($("content").offsetHeight - 2) + "px";
196 map.setCenter(centre, zoom);
199 function handleResize() {
200 if (brokenContentSize) {
209 window.onload = handleResize;
210 window.onresize = handleResize;
212 <% if params['action'] == 'export' %>
213 <%= remote_function :url => { :controller => 'export', :action => 'start' } %>