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 <% layers = params['layers'] %>
14 <% elsif params['mlon'] and params['mlat'] %>
15 <% lon = params['mlon'] %>
16 <% lat = params['mlat'] %>
17 <% zoom = params['zoom'] || '12' %>
18 <% layers = params['layers'] %>
19 <% elsif cookies.key?("location") %>
20 <% lon,lat,zoom,layers = cookies["location"].value.first.split(",") %>
21 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
22 <% lon = @user.home_lon %>
23 <% lat = @user.home_lat %>
28 <% zoom = params['zoom'] || '5' %>
29 <% layers = params['layers'] %>
32 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
33 <%= javascript_include_tag 'map.js' %>
36 <script src="http://www.mappam.com/javascripts/mappam.js" type="text/javascript"></script>
40 <script type="text/javascript">
42 var ie = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;
46 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
47 var zoom = <%= zoom %>;
48 var layers = "<%= layers %>";
50 <% if params['scale'] and params['scale'].length > 0 then %>
51 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
54 var map = createMap("map", centre, zoom);
57 addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
64 map.events.register("moveend", map, updateLocation);
68 if ( window.location.hostname == "www.openstreetmap.org" ) {
69 mappam.register( map, '10011756636067178496', '1');
70 } else if( window.location.hostname == "openstreetmap.org" ) {
71 mappam.register( map, '6738410720121976832', '1');
75 document.getElementById('map_OpenLayers_ViewPort').style.position = 'absolute';
81 function updateLocation() {
82 var lonlat = mercatorToLonLat(map.getCenter());
83 var zoom = map.getZoom();
84 var layers = getMapLayers();
86 updatelinks(lonlat.lon, lonlat.lat, zoom, layers);
88 document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers;
91 function getStyle( el, property ) {
93 if( el.currentStyle ) {
94 style = el.currentStyle[property];
95 } else if( window.getComputedStyle ) {
96 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
98 style = el.style[property];
103 function handleResize() {
104 var el = document.getElementById( 'map' );
105 var left = getStyle( el, 'left' );
106 var top = getStyle( el, 'top' );
107 var bottom = getStyle( el, 'bottom' );
108 var right = getStyle( el, 'right' );
109 var width = el.old_width;
112 width = getStyle( el, 'width' );
114 var height = el.old_height;
116 height = getStyle( el, 'height' );
119 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
120 if( typeof( window.innerWidth ) == 'number' ) {
121 pwidth = window.innerWidth;
122 pheight = window.innerHeight;
123 } else if( document.documentElement &&
124 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
125 pwidth = document.documentElement.clientWidth;
126 pheight = document.documentElement.clientHeight;
127 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
128 pwidth = document.body.clientWidth;
129 pheight = document.body.clientHeight;
132 pwidth = el.offsetParent.offsetWidth;
133 pheight = el.offsetParent.offsetHeight;
135 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
136 el.old_width = width;
137 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
138 el.style.width = new_width + 'px';
140 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
141 el.old_height = height;
142 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
143 el.style.height = new_height + 'px';
146 el.style.display = 'none';
147 setTimeout( function() { el.style.display = ''; }, 200 );
151 window.onresize = handleResize;
154 window.onload = init;