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>
28 <script type="text/javascript">
30 var ie6 = ! ( window.addEventListener || window.XMLHttpRequest );
34 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
35 var zoom = <%= zoom %>;
37 <% if params['scale'] and params['scale'].length > 0 then %>
38 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
41 var map = createMap("map", centre, zoom);
44 addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
47 map.events.register("moveend", map, updateLocation);
51 if ( window.location.hostname == "www.openstreetmap.org" ) {
52 mappam.register( map, '10011756636067178496', '1');
53 } else if( window.location.hostname == "openstreetmap.org" ) {
54 mappam.register( map, '6738410720121976832', '1');
58 document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
64 function updateLocation() {
65 var lonlat = mercatorToLonLat(map.getCenter());
66 var zoom = map.getZoom();
68 updatelinks(lonlat.lon, lonlat.lat, zoom);
71 function getStyle( el, property ) {
73 if( el.currentStyle ) {
74 style = el.currentStyle[property];
75 } else if( window.getComputedStyle ) {
76 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
78 style = el.style[property];
83 function handleResize() {
84 var el = document.getElementById( 'map' );
85 var left = getStyle( el, 'left' );
86 var top = getStyle( el, 'top' );
87 var bottom = getStyle( el, 'bottom' );
88 var right = getStyle( el, 'right' );
89 var width = el.old_width;
92 width = getStyle( el, 'width' );
94 var height = el.old_height;
96 height = getStyle( el, 'height' );
99 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
100 if( typeof( window.innerWidth ) == 'number' ) {
101 pwidth = window.innerWidth;
102 pheight = window.innerHeight;
103 } else if( document.documentElement &&
104 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
105 pwidth = document.documentElement.clientWidth;
106 pheight = document.documentElement.clientHeight;
107 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
108 pwidth = document.body.clientWidth;
109 pheight = document.body.clientHeight;
112 pwidth = el.offsetParent.offsetWidth;
113 pheight = el.offsetParent.offsetHeight;
115 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
116 el.old_width = width;
117 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
118 el.style.width = new_width + 'px';
120 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
121 el.old_height = height;
122 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
123 el.style.height = new_height + 'px';
126 el.style.display = 'none';
127 setTimeout( function() {
128 el.style.display = '';
133 window.onresize = handleResize;
136 window.onload = init;