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' %>
12 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
15 <div id="attribution">
18 <td align="left">http://creativecommons.org/licenses/by-sa/2.0/</td>
19 <td align="right">http://openstreetmap.org/</td>
22 <td colspan="2" align="center">
23 Licensed under the Creative Commons Attribution-Share Alike 2.0 license
24 by the OpenStreetMap project and it's contributors.
29 <% if params['mlon'] and params['mlat'] %>
31 <% mlon = h(params['mlon']) %>
32 <% mlat = h(params['mlat']) %>
35 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
37 <% minlon = h(params['minlon']) %>
38 <% minlat = h(params['minlat']) %>
39 <% maxlon = h(params['maxlon']) %>
40 <% maxlat = h(params['maxlat']) %>
43 <% if params['lon'] and params['lat'] %>
44 <% lon = h(params['lon']) %>
45 <% lat = h(params['lat']) %>
46 <% zoom = h(params['zoom'] || '5') %>
47 <% layers = h(params['layers']) %>
48 <% elsif params['mlon'] and params['mlat'] %>
49 <% lon = h(params['mlon']) %>
50 <% lat = h(params['mlat']) %>
51 <% zoom = h(params['zoom'] || '12') %>
52 <% layers = h(params['layers']) %>
53 <% elsif cookies.key?("location") %>
54 <% lon,lat,zoom,layers = cookies["location"].split(",") %>
55 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
56 <% lon = @user.home_lon %>
57 <% lat = @user.home_lat %>
60 <% session[:location] = OSM::IPLocation(request.env['REMOTE_ADDR']) unless session[:location] %>
61 <% if session[:location] %>
63 <% minlon = session[:location][:minlon] %>
64 <% minlat = session[:location][:minlat] %>
65 <% maxlon = session[:location][:maxlon] %>
66 <% maxlat = session[:location][:maxlat] %>
70 <% zoom = h(params['zoom'] || '5') %>
71 <% layers = h(params['layers']) %>
75 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
76 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
77 <%= javascript_include_tag 'map.js' %>
80 <script type="text/javascript" defer="defer">
82 var brokenContentSize = $("content").offsetWidth == 0;
87 map = createMap("map");
90 var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
94 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
95 var zoom = <%= zoom %>;
97 <% if params['scale'] and params['scale'].length > 0 then %>
98 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
101 setMapCenter(centre, zoom);
105 setMapLayers("<%= layers %>");
109 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
112 map.events.register("zoomend", map, updateKey);
114 map.events.register("moveend", map, updateLocation);
115 map.events.register("changelayer", map, updateLocation);
121 function getPosition() {
122 return getMapCenter();
125 function setPosition(lat, lon, zoom) {
126 var centre = new OpenLayers.LonLat(lon, lat);
128 setMapCenter(centre, zoom);
131 removeMarkerFromMap(marker);
133 marker = addMarkerToMap(centre, getArrowIcon());
136 function updateLocation() {
137 var lonlat = getMapCenter();
138 var zoom = map.getZoom();
139 var layers = getMapLayers();
141 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
143 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
146 function resizeContent() {
147 var content = $("content");
148 var rightMargin = parseInt(getStyle(content, "right"));
149 var bottomMargin = parseInt(getStyle(content, "bottom"));
151 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
152 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
155 function resizeMap() {
156 var centre = map.getCenter();
157 var zoom = map.getZoom();
158 var sidebar_width = $("sidebar").offsetWidth;
160 if (sidebar_width > 0) {
161 sidebar_width = sidebar_width + 5
164 $("map").style.left = (sidebar_width) + "px";
165 $("map").style.width = ($("content").offsetWidth - sidebar_width) + "px";
166 $("map").style.height = ($("content").offsetHeight - 2) + "px";
168 map.setCenter(centre, zoom);
171 function handleResize() {
172 if (brokenContentSize) {
181 window.onload = handleResize;
182 window.onresize = handleResize;