1 <%= render :partial => 'search' %>
3 <% if params['mlon'] and params['mlat'] %>
5 <% mlon = params['mlon'] %>
6 <% mlat = params['mlat'] %>
7 <% lon = params['mlon'] %>
8 <% lat = params['mlat'] %>
9 <% zoom = params['zoom'] || '12' %>
10 <% elsif @user and params['lon'].nil? and params['lat'].nil? %>
11 <% lon = @user.home_lon %>
12 <% lat = @user.home_lat %>
15 <% lon = params['lon'] || '-0.1' %>
16 <% lat = params['lat'] || '51.5' %>
17 <% zoom = params['zoom'] || '4' %>
20 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
21 <%= javascript_include_tag 'map.js' %>
23 <script type="text/javascript">
25 var ie6 = ! ( window.addEventListener || window.XMLHttpRequest );
29 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
30 var zoom = <%= zoom %>;
32 <% if params['scale'] and params['scale'].length > 0 then %>
33 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
36 var map = createMap("map", centre, zoom);
39 addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
42 map.events.register("moveend", map, updateLocation);
45 document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
51 function updateLocation() {
52 var lonlat = mercatorToLonLat(map.getCenter());
53 var zoom = map.getZoom();
55 updatelinks(lonlat.lon, lonlat.lat, zoom);
58 function getStyle( el, property ) {
60 if( el.currentStyle ) {
61 style = el.currentStyle[property];
62 } else if( window.getComputedStyle ) {
63 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
65 style = el.style[property];
70 function handleResize() {
71 var el = document.getElementById( 'map' );
72 var left = getStyle( el, 'left' );
73 var top = getStyle( el, 'top' );
74 var bottom = getStyle( el, 'bottom' );
75 var right = getStyle( el, 'right' );
76 var width = el.old_width;
78 width = getStyle( el, 'width' );
80 var height = el.old_height;
82 height = getStyle( el, 'height' );
85 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
86 if( typeof( window.innerWidth ) == 'number' ) {
87 pwidth = window.innerWidth;
88 height = window.innerHeight;
89 } else if( document.documentElement &&
90 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
91 pwidth = document.documentElement.clientWidth;
92 pheight = document.documentElement.clientHeight;
93 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
94 pwidth = document.body.clientWidth;
95 pheight = document.body.clientHeight;
98 pwidth = el.offsetParent.offsetWidth;
99 pheight = el.offsetParent.offsetHeight;
101 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
102 el.old_width = width;
103 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
104 el.style.width = new_width + 'px';
106 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
107 el.old_height = height;
108 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
109 el.style.height = new_height + 'px';
112 el.style.display = 'none';
113 setTimeout( function() {
114 el.style.display = '';
119 window.onresize = handleResize;
122 window.onload = init;