1 <%= render :partial => 'search' %>
3 <% if params['mlon'] and params['mlat'] %>
5 <% mlon = params['mlon'] %>
6 <% mlat = params['mlat'] %>
9 <% if params['lon'] and params['lat'] %>
10 <% lon = params['lon'] %>
11 <% lat = params['lat'] %>
12 <% zoom = params['zoom'] || '5' %>
13 <% elsif params['mlon'] and params['mlat'] %>
14 <% lon = params['mlon'] %>
15 <% lat = params['mlat'] %>
16 <% zoom = params['zoom'] || '12' %>
18 <% lon = @user.home_lon %>
19 <% lat = @user.home_lat %>
24 <% zoom = params['zoom'] || '5' %>
27 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
28 <%= javascript_include_tag 'map.js' %>
31 <script src="http://www.mappam.com/javascripts/mappam.js" type="text/javascript"></script>
35 <script type="text/javascript">
37 var ie = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;
41 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
42 var zoom = <%= zoom %>;
44 <% if params['scale'] and params['scale'].length > 0 then %>
45 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
48 var map = createMap("map", centre, zoom);
51 addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
54 map.events.register("moveend", map, updateLocation);
58 if ( window.location.hostname == "www.openstreetmap.org" ) {
59 mappam.register( map, '10011756636067178496', '1');
60 } else if( window.location.hostname == "openstreetmap.org" ) {
61 mappam.register( map, '6738410720121976832', '1');
65 document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
71 function updateLocation() {
72 var lonlat = mercatorToLonLat(map.getCenter());
73 var zoom = map.getZoom();
75 updatelinks(lonlat.lon, lonlat.lat, zoom);
78 function getStyle( el, property ) {
80 if( el.currentStyle ) {
81 style = el.currentStyle[property];
82 } else if( window.getComputedStyle ) {
83 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
85 style = el.style[property];
90 function handleResize() {
91 var el = document.getElementById( 'map' );
92 var left = getStyle( el, 'left' );
93 var top = getStyle( el, 'top' );
94 var bottom = getStyle( el, 'bottom' );
95 var right = getStyle( el, 'right' );
96 var width = el.old_width;
99 width = getStyle( el, 'width' );
101 var height = el.old_height;
103 height = getStyle( el, 'height' );
106 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
107 if( typeof( window.innerWidth ) == 'number' ) {
108 pwidth = window.innerWidth;
109 pheight = window.innerHeight;
110 } else if( document.documentElement &&
111 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
112 pwidth = document.documentElement.clientWidth;
113 pheight = document.documentElement.clientHeight;
114 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
115 pwidth = document.body.clientWidth;
116 pheight = document.body.clientHeight;
119 pwidth = el.offsetParent.offsetWidth;
120 pheight = el.offsetParent.offsetHeight;
122 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
123 el.old_width = width;
124 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
125 el.style.width = new_width + 'px';
127 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
128 el.old_height = height;
129 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
130 el.style.height = new_height + 'px';
133 el.style.display = 'none';
134 setTimeout( function() { el.style.display = ''; }, 200 );
138 window.onresize = handleResize;
141 window.onload = init;