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="/javascripts/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 = "http://www.openstreetmap.org/javascripts/img/404.png";
60 map = new OpenLayers.Map( "map",
61 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, 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.addControl(new OpenLayers.Control.LayerSwitcher());
78 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
80 map.events.register("moveend", map, updateLocation);
81 document.getElementById( 'map_OpenLayers_ViewPort' ).style.position = 'absolute';
88 function getTileURL( bounds ) {
89 var res = this.map.getResolution();
90 var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
91 var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
92 var z = this.map.getZoom();
93 return this.url + z + "/" + x + "/" + y + "." + this.type;
96 function updateLocation() {
97 var lonlat = map.getCenter();
99 var lon_deg = (lonlat.lon / 20037508.34) * 180;
100 var lat_deg = (lonlat.lat / 20037508.34) * 180;
101 var PI = 3.14159265358979323846;
102 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
103 var zoom = map.getZoom();
105 updatelinks(lon_deg,lat_deg,zoom);
108 function getStyle( el, property ) {
110 if( el.currentStyle ) {
111 style = el.currentStyle[property];
112 } else if( window.getComputedStyle ) {
113 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
115 style = el.style[property];
120 function handleResize() {
121 var el = document.getElementById( 'map' );
122 var left = getStyle( el, 'left' );
123 var top = getStyle( el, 'top' );
124 var bottom = getStyle( el, 'bottom' );
125 var right = getStyle( el, 'right' );
126 var width = el.old_width;
128 width = getStyle( el, 'width' );
130 var height = el.old_height;
132 height = getStyle( el, 'height' );
135 if( el.offsetParent.nodeName == 'BODY' || el.offsetParent.nodeName == 'HTML' ) {
136 if( typeof( window.innerWidth ) == 'number' ) {
137 pwidth = window.innerWidth;
138 height = window.innerHeight;
139 } else if( document.documentElement &&
140 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
141 pwidth = document.documentElement.clientWidth;
142 pheight = document.documentElement.clientHeight;
143 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
144 pwidth = document.body.clientWidth;
145 pheight = document.body.clientHeight;
148 pwidth = el.offsetParent.offsetWidth;
149 pheight = el.offsetParent.offsetHeight;
151 if( left != 'auto' && right != 'auto' && width == 'auto' ) {
152 el.old_width = width;
153 var new_width = (pwidth - el.offsetLeft - parseInt( right ) );
154 el.style.width = new_width + 'px';
156 if( top != 'auto' && bottom != 'auto' && height == 'auto' ) {
157 el.old_height = height;
158 var new_height = (pheight - el.offsetTop - parseInt( bottom ) );
159 el.style.height = new_height + 'px';
162 el.style.display = 'none';
163 setTimeout( function() {
164 el.style.display = '';
169 window.onresize = handleResize;
171 window.onload = init;