4 <%= start_form_tag :controller => 'geocoder', :action => 'search' %>
5 <%= text_field 'query', 'postcode'%>
6 <%= text_field 'query', 'place_name'%>
7 <%= submit_tag 'Search' %>
9 <div id="postcode-helper">
12 <div id="placename-helper">
20 <% lon = params['lon'] || '-0.1' %>
21 <% lat = params['lat'] || '51.5' %>
22 <% zoom = params['zoom'] || '4' %>
24 <script type="text/javascript">
27 var zoom = <%= zoom %>;
28 var PI = 3.14159265358979323846;
30 <% if params['scale'] and params['scale'].length > 0 then %>
31 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
34 lon = lon * 20037508.34 / 180;
35 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
36 lat = lat * 20037508.34 / 180;
39 <script type="text/javascript" src="/javascripts/OpenLayers.js"></script>
41 <script type="text/javascript">
48 OpenLayers.Util.onImageLoadError = function() {
49 this.src = "http://www.openstreetmap.org/javascript/img/404.png";
51 map = new OpenLayers.Map( "map",
52 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, maxResolution:156543, units:'meters', projection: "EPSG:41001"} );
53 layer = new OpenLayers.Layer.LikeGoogle( "Mapnik", "http://tile.openstreetmap.org/", {type:'png'} );
55 layer = new OpenLayers.Layer.LikeGoogle( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png'} );
58 map.addControl(new OpenLayers.Control.LayerSwitcher());
59 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
61 map.events.register("moveend", map, function() {
62 var lonlat = map.getCenter();
64 var lon_deg = (lonlat.lon / 20037508.34) * 180;
65 var lat_deg = (lonlat.lat / 20037508.34) * 180;
66 var PI = 3.14159265358979323846;
67 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
68 var zoom = map.getZoom();
69 updatelinks(lon_deg,lat_deg,zoom);