4 <%= start_form_tag :controller => 'geocoder', :action => 'search' %>
5 <%= text_field 'query', 'postcode'%>
6 <%= text_field 'query', 'place_name'%>
7 <%= submit_tag 'Search' %>
10 <div id="geocoder-attribution">
11 Geolocation provided by <a href="http://npemap.org.uk/">npemap.org.uk</a>,
12 <a href="http://geocoder.us/">geocoder.us</a>, <a href="http://geocoder.ca/">geocoder.ca</a>
13 and <a href="http://www.geonames.org/">geonames.org</a>
15 <div id="postcode-helper">
16 eg: SW15 6JH, 95472 or H2L4C1
18 <div id="placename-helper">
23 <% lon = params['lon'] || '-0.1' %>
24 <% lat = params['lat'] || '51.5' %>
25 <% zoom = params['zoom'] || '4' %>
27 <script type="text/javascript">
30 var zoom = <%= zoom %>;
31 var PI = 3.14159265358979323846;
33 <% if params['scale'] and params['scale'].length > 0 then %>
34 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
37 lon = lon * 20037508.34 / 180;
38 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
39 lat = lat * 20037508.34 / 180;
42 <script type="text/javascript" src="/javascripts/OpenLayers.js"></script>
44 <script type="text/javascript">
51 OpenLayers.Util.onImageLoadError = function() {
52 this.src = "http://www.openstreetmap.org/javascript/img/404.png";
54 map = new OpenLayers.Map( "map",
55 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, maxResolution:156543, units:'meters', projection: "EPSG:41001"} );
56 layer = new OpenLayers.Layer.LikeGoogle( "Mapnik", "http://tile.openstreetmap.org/", {type:'png'} );
58 layer = new OpenLayers.Layer.LikeGoogle( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png'} );
61 map.addControl(new OpenLayers.Control.LayerSwitcher());
62 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
64 map.events.register("moveend", map, function() {
65 var lonlat = map.getCenter();
67 var lon_deg = (lonlat.lon / 20037508.34) * 180;
68 var lat_deg = (lonlat.lat / 20037508.34) * 180;
69 var PI = 3.14159265358979323846;
70 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
71 var zoom = map.getZoom();
72 updatelinks(lon_deg,lat_deg,zoom);