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' %>
17 <% elsif cookies.key?("location") %>
18 <% lon,lat,zoom = cookies["location"].value.first.split(",") %>
19 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
20 <% lon = @user.home_lon %>
21 <% lat = @user.home_lat %>
26 <% zoom = params['zoom'] || '5' %>
29 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
30 <%= javascript_include_tag 'map.js' %>
33 <script src="http://www.mappam.com/javascripts/mappam.js" type="text/javascript"></script>
37 <script type="text/javascript">
39 var ie = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;
43 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
44 var zoom = <%= zoom %>;
46 <% if params['scale'] and params['scale'].length > 0 then %>
47 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
50 var map = createMap("map", centre, zoom);
53 addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
56 map.events.register("moveend", map, updateLocation);
60 if ( window.location.hostname == "www.openstreetmap.org" ) {
61 mappam.register( map, '10011756636067178496', '1');
62 } else if( window.location.hostname == "openstreetmap.org" ) {
63 mappam.register( map, '6738410720121976832', '1');
67 document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
73 function updateLocation() {
74 var lonlat = mercatorToLonLat(map.getCenter());
75 var zoom = map.getZoom();
77 updatelinks(lonlat.lon, lonlat.lat, zoom);
79 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom;
82 function getStyle( el, property ) {
84 if( el.currentStyle ) {
85 style = el.currentStyle[property];
86 } else if( window.getComputedStyle ) {
87 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
89 style = el.style[property];
94 function handleResize() {
95 var el = document.getElementById( 'map' );
96 var left = getStyle( el, 'left' );
97 var top = getStyle( el, 'top' );
98 var bottom = getStyle( el, 'bottom' );
99 var right = getStyle( el, 'right' );
100 var width = el.old_width;
103 width = getStyle( el, 'width' );
105 var height = el.old_height;
107 height = getStyle( el, 'height' );
110 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
111 if( typeof( window.innerWidth ) == 'number' ) {
112 pwidth = window.innerWidth;
113 pheight = window.innerHeight;
114 } else if( document.documentElement &&
115 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
116 pwidth = document.documentElement.clientWidth;
117 pheight = document.documentElement.clientHeight;
118 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
119 pwidth = document.body.clientWidth;
120 pheight = document.body.clientHeight;
123 pwidth = el.offsetParent.offsetWidth;
124 pheight = el.offsetParent.offsetHeight;
126 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
127 el.old_width = width;
128 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
129 el.style.width = new_width + 'px';
131 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
132 el.old_height = height;
133 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
134 el.style.height = new_height + 'px';
137 el.style.display = 'none';
138 setTimeout( function() { el.style.display = ''; }, 200 );
142 window.onresize = handleResize;
145 window.onload = init;