Ignore:
Timestamp:
Nov 19, 2006, 12:06:16 PM (13 years ago)
Author:
David Sheldon
Message:

use the same code on the front page for the searching as we use on the main page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/static/index.html

    r352 r374  
    77<script src="tiles/jsr_class.js" type="text/javascript"></script>
    88<script src="tiles/jscoord-1.1.1.js" type="text/javascript"></script>
     9<script src="tiles/prototype.js" type="text/javascript"></script>
     10<script src="find.js" type="text/javascript"></script>
    911
    1012<div id="body">
     
    6466document.write(' <label for="where">Place:</label><input id="where" name="where" /> <input type="submit" name="Zoom To" value="Go" />');
    6567</script>
     68
    6669</p>
     70
     71<div id="geonames_results_window">
     72  <div class="close"><a href="javascript:hideGeonamesPopup()" title="close">X</a></div>
     73  <div id="geonames_results"></div>
     74</div>
     75
    6776</form>
    6877      <span class="terms">Functionality by <a href="http://www.geonames.org/">Geonames</a>.</span>
     
    7483var xOffset = 62;
    7584
    76 function find() {
    77    request = 'http://ws.geonames.org/searchJSON?name=' +  encodeURIComponent(document.getElementById('where').value)  + '&maxRows=1&callback=getLocation&country=GB&fclass=P&style=SHORT';
    78   aObj = new JSONscriptRequest(request);
    79   // Build the script tag
    80   aObj.buildScriptTag();
    81   // Execute (add) the script tag
    82   aObj.addScriptTag();
    83   return false;
     85function gotoLocation(easting, northing, zoom) {
     86    location.href = urlFor(easting, northing, zoom);
    8487}
    85 
    86 // this function will be called by our JSON callback
    87 function getLocation(jData) {
    88   if (jData == null) {
    89     // There was a problem parsing search results
    90     return;
    91   }
    92 
    93   var geonames = jData.geonames;
    94   if (geonames.length > 0) {
    95     var name = geonames[0];
    96     var ll = new LatLng(name.lat,name.lng);
    97     ll.WGS84ToOSGB36();
    98     var en = ll.toOSRef();
    99     var easting = Math.round(en.easting/1000);
    100     var northing = Math.round(en.northing/1000);
    101     location.href = urlFor(easting, northing, 1);
    102   }
    103   else {
    104     alert("Sorry, can't find that location");
    105   }
    106 }
    107 
    10888
    10989
Note: See TracChangeset for help on using the changeset viewer.