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' %>
24 <script src="http://www.mappam.com/javascripts/mappam.js" type="text/javascript"></script>
29 <script type="text/javascript">
31 var ie6 = ! ( window.addEventListener || window.XMLHttpRequest );
35 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
36 var zoom = <%= zoom %>;
38 <% if params['scale'] and params['scale'].length > 0 then %>
39 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
42 var map = createMap("map", centre, zoom);
45 addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
48 map.events.register("moveend", map, updateLocation);
52 if( window.location.host.match( /^www/ ) ) {
53 mappam.register( map, '10011756636067178496', '1');
55 mappam.register( map, '6738410720121976832', '1');
60 document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
66 function updateLocation() {
67 var lonlat = mercatorToLonLat(map.getCenter());
68 var zoom = map.getZoom();
70 updatelinks(lonlat.lon, lonlat.lat, zoom);
73 function getStyle( el, property ) {
75 if( el.currentStyle ) {
76 style = el.currentStyle[property];
77 } else if( window.getComputedStyle ) {
78 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
80 style = el.style[property];
85 function handleResize() {
86 var el = document.getElementById( 'map' );
87 var left = getStyle( el, 'left' );
88 var top = getStyle( el, 'top' );
89 var bottom = getStyle( el, 'bottom' );
90 var right = getStyle( el, 'right' );
91 var width = el.old_width;
93 width = getStyle( el, 'width' );
95 var height = el.old_height;
97 height = getStyle( el, 'height' );
100 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
101 if( typeof( window.innerWidth ) == 'number' ) {
102 pwidth = window.innerWidth;
103 height = window.innerHeight;
104 } else if( document.documentElement &&
105 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
106 pwidth = document.documentElement.clientWidth;
107 pheight = document.documentElement.clientHeight;
108 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
109 pwidth = document.body.clientWidth;
110 pheight = document.body.clientHeight;
113 pwidth = el.offsetParent.offsetWidth;
114 pheight = el.offsetParent.offsetHeight;
116 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
117 el.old_width = width;
118 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
119 el.style.width = new_width + 'px';
121 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
122 el.old_height = height;
123 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
124 el.style.height = new_height + 'px';
127 el.style.display = 'none';
128 setTimeout( function() {
129 el.style.display = '';
134 window.onresize = handleResize;
137 window.onload = init;