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 <script type="text/javascript">
11 var mlat = <%= lat %>;
12 var mlon = <%= lon %>;
14 <% elsif @user and params['lon'].nil? and params['lat'].nil? %>
15 <% lon = @user.home_lon %>
16 <% lat = @user.home_lat %>
19 <% lon = params['lon'] || '-0.1' %>
20 <% lat = params['lat'] || '51.5' %>
21 <% zoom = params['zoom'] || '4' %>
26 <script type="text/javascript">
29 var zoom = <%= zoom %>;
30 var PI = 3.14159265358979323846;
34 <% if params['scale'] and params['scale'].length > 0 then %>
35 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
38 lon = lon * 20037508.34 / 180;
39 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
40 lat = lat * 20037508.34 / 180;
42 mlon = mlon * 20037508.34 / 180;
43 mlat = Math.log(Math.tan( (90 + mlat) * PI / 360)) / (PI / 180);
44 mlat = mlat * 20037508.34 / 180;
48 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
50 <script type="text/javascript">
52 var map, layer, markers;
53 var ie6 = ! ( window.addEventListener || window.XMLHttpRequest );
57 OpenLayers.Util.onImageLoadError = function() {
58 this.src = OpenLayers.Util.getImagesLocation() + "404.png";
60 map = new OpenLayers.Map( "map",
61 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), numZoomLevels:19, maxResolution:156543, units:'meters', projection: "EPSG:41001"} );
62 layer = new OpenLayers.Layer.TMS( "Mapnik", "http://tile.openstreetmap.org/", {type:'png', getURL:getTileURL} );
64 layer = new OpenLayers.Layer.TMS( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png', getURL:getTileURL} );
70 markers = new OpenLayers.Layer.Markers("markers");
71 map.addLayer(markers);
73 marker = new OpenLayers.Marker(new OpenLayers.LonLat(mlon,mlat));
74 markers.addMarker(marker);
77 map.setOptions({theme:''});
78 map.addControl(new OpenLayers.Control.LayerSwitcher());
79 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
81 map.events.register("moveend", map, updateLocation);
82 document.getElementById( 'map_OpenLayers_ViewPort' ).style.position = 'absolute';
89 function getTileURL( bounds ) {
90 var res = this.map.getResolution();
91 var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
92 var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
93 var z = this.map.getZoom();
94 return this.url + z + "/" + x + "/" + y + "." + this.type;
97 function updateLocation() {
98 var lonlat = map.getCenter();
100 var lon_deg = (lonlat.lon / 20037508.34) * 180;
101 var lat_deg = (lonlat.lat / 20037508.34) * 180;
102 var PI = 3.14159265358979323846;
103 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
104 var zoom = map.getZoom();
106 updatelinks(lon_deg,lat_deg,zoom);
109 function getStyle( el, property ) {
111 if( el.currentStyle ) {
112 style = el.currentStyle[property];
113 } else if( window.getComputedStyle ) {
114 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
116 style = el.style[property];
121 function handleResize() {
122 var el = document.getElementById( 'map' );
123 var left = getStyle( el, 'left' );
124 var top = getStyle( el, 'top' );
125 var bottom = getStyle( el, 'bottom' );
126 var right = getStyle( el, 'right' );
127 var width = el.old_width;
129 width = getStyle( el, 'width' );
131 var height = el.old_height;
133 height = getStyle( el, 'height' );
136 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
137 if( typeof( window.innerWidth ) == 'number' ) {
138 pwidth = window.innerWidth;
139 height = window.innerHeight;
140 } else if( document.documentElement &&
141 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
142 pwidth = document.documentElement.clientWidth;
143 pheight = document.documentElement.clientHeight;
144 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
145 pwidth = document.body.clientWidth;
146 pheight = document.body.clientHeight;
149 pwidth = el.offsetParent.offsetWidth;
150 pheight = el.offsetParent.offsetHeight;
152 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
153 el.old_width = width;
154 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
155 el.style.width = new_width + 'px';
157 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
158 el.old_height = height;
159 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
160 el.style.height = new_height + 'px';
163 el.style.display = 'none';
164 setTimeout( function() {
165 el.style.display = '';
170 window.onresize = handleResize;
172 window.onload = init;