1 <%= render :partial => 'search', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
5 <% if params['mlon'] and params['mlat'] %>
7 <% mlon = params['mlon'] %>
8 <% mlat = params['mlat'] %>
11 <% if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] %>
13 <% minlon = params['minlon'] %>
14 <% minlat = params['minlat'] %>
15 <% maxlon = params['maxlon'] %>
16 <% maxlat = params['maxlat'] %>
19 <% if params['lon'] and params['lat'] %>
20 <% lon = params['lon'] %>
21 <% lat = params['lat'] %>
22 <% zoom = params['zoom'] || '5' %>
23 <% layers = params['layers'] %>
24 <% elsif params['mlon'] and params['mlat'] %>
25 <% lon = params['mlon'] %>
26 <% lat = params['mlat'] %>
27 <% zoom = params['zoom'] || '12' %>
28 <% layers = params['layers'] %>
29 <% elsif cookies.key?("location") %>
30 <% lon,lat,zoom,layers = cookies["location"].value.first.split(",") %>
31 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
32 <% lon = @user.home_lon %>
33 <% lat = @user.home_lat %>
38 <% zoom = params['zoom'] || '5' %>
39 <% layers = params['layers'] %>
42 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
43 <%= javascript_include_tag 'map.js' %>
46 <script type="text/javascript">
48 var brokenContentSize = $("content").offsetWidth == 0;
53 map = createMap("map");
56 var min = lonLatToMercator(new OpenLayers.LonLat(<%= minlon %>, <%= minlat %>));
57 var max = lonLatToMercator(new OpenLayers.LonLat(<%= maxlon %>, <%= maxlat %>));
58 var bbox = new OpenLayers.Bounds(min.lon, min.lat, max.lon, max.lat);
60 map.zoomToExtent(bbox);
62 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
63 var zoom = <%= zoom %>;
65 <% if params['scale'] and params['scale'].length > 0 then %>
66 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
69 map.setCenter(centre, zoom);
73 marker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
77 setMapLayers("<%= layers %>");
80 map.events.register("moveend", map, updateLocation);
86 function setPosition(lat, lon, zoom) {
87 var centre = lonLatToMercator(new OpenLayers.LonLat(lon, lat));
89 map.setCenter(centre, zoom);
92 removeMarkerFromMap(marker);
94 marker = addMarkerToMap(centre);
97 function updateLocation() {
98 var lonlat = mercatorToLonLat(map.getCenter());
99 var zoom = map.getZoom();
100 var layers = getMapLayers();
102 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
104 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
107 function resizeContent() {
108 var content = $("content");
109 var rightMargin = parseInt(getStyle(content, "right"));
110 var bottomMargin = parseInt(getStyle(content, "bottom"));
112 content.style.width = document.documentElement.clientWidth - content.offsetLeft - rightMargin;
113 content.style.height = document.documentElement.clientHeight - content.offsetTop - bottomMargin;
116 function resizeMap() {
117 var centre = map.getCenter();
118 var zoom = map.getZoom();
119 var search_results_width = $("search_results").offsetWidth;
121 if (search_results_width > 0) {
122 search_results_width = search_results_width + 5
125 $("map").style.left = (search_results_width) + "px";
126 $("map").style.width = ($("content").offsetWidth - search_results_width) + "px";
127 $("map").style.height = ($("content").offsetHeight - 2) + "px";
129 map.setCenter(centre, zoom);
132 function handleResize() {
133 if (brokenContentSize) {
140 window.onresize = handleResize;
141 window.onload = init;