Changeset 144


Ignore:
Timestamp:
Oct 23, 2006, 6:56:23 PM (13 years ago)
Author:
David Sheldon
Message:

Search now on the map page too, and added credit for Geonames.

Location:
trunk/npemap.org.uk/static
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/static/default.css

    r132 r144  
    3535    margin: 4px;
    3636}
     37
     38span.terms {
     39 margin-top: 0px;
     40 font-family: sans;
     41 font-size: 65%;
     42 line-height: 100%;
     43}
  • trunk/npemap.org.uk/static/index.html

    r143 r144  
    4747
    4848<form onsubmit="return find()">
    49 <p><label for="where">Place Name</label>
    50 <input id="where" name="where" /></p>
    51 <p><input type="submit" name="Zoom To" /></p>
     49<p><label for="where">Place:</label>
     50<input id="where" name="where" />
     51<input type="submit" name="Zoom To" value="Go" /></p>
    5252</form>
     53      <span class="terms">Functionality by <a href="http://geonames.org/">Geonames</a>.</span>
    5354</div>
    5455
     
    8384    var easting = Math.round(en.easting/1000);
    8485    var northing = Math.round(en.northing/1000);
    85     window.location = urlFor(easting, northing, 1);
     86    location.href = urlFor(easting, northing, 1);
    8687  }
    8788  else {
     
    101102        var y = (img.height-(YAHOO.util.Event.getPageY(e) - imgPos[1])) * 2;
    102103
    103         window.location=(urlFor(x, y, 1));
     104        location.href=(urlFor(x, y, 1));
    104105
    105106        YAHOO.util.Event.stopEvent(e);
  • trunk/npemap.org.uk/static/tiles/map.html

    r142 r144  
    1111<script src="event.js"></script>
    1212<!-- Our functions -->
     13<script src="jsr_class.js"></script>
     14<script src="jscoord-1.1.1.js"></script>
    1315<script src="mapTiles.js"></script>
    1416        <h1 id=theTitle>New Popular Edition Maps</h1>
     
    5052                        <a href="/reportBug.html">problem?</a>
    5153                </div>
     54                <div>
     55      <form onsubmit="return find()">
     56      <p><label for="where">Place name:</label><br/>
     57      <input id="where" name="where" />
     58      <input type="submit" name="Zoom To" value="Go" /></p>
     59      </form>
     60      <span class="terms">Functionality by <a href="http://geonames.org/">Geonames</a>.</span>
     61                </div>
     62</div>
    5263</div>
    5364<div id="map_container" style="float:left">
  • trunk/npemap.org.uk/static/tiles/mapTiles.js

    r142 r144  
    224224}
    225225
     226function gotoLocation(easting, northing, zoom) {
     227  offsetGridX = easting;
     228  offsetGridY = northing;
     229  zoomLevel = zoom;
     230  refreshGrid();
     231}
     232
    226233
    227234// Need to use substring for IE, and it doesn't take negative numbers.
     
    360367
    361368
    362 
    363 
     369function find() {
     370   request = 'http://ws.geonames.org/searchJSON?name=' +  encodeURIComponent(document.getElementById('where').value)  + '&maxRows=1&callback=getLocation&country=GB&fclass=P&style=SHORT';
     371  aObj = new JSONscriptRequest(request);
     372  // Build the script tag
     373  aObj.buildScriptTag();
     374  // Execute (add) the script tag
     375  aObj.addScriptTag();
     376  return false;
     377}
     378// this function will be called by our JSON callback
     379function getLocation(jData) {
     380  if (jData == null) {
     381    // There was a problem parsing search results
     382    return;
     383  }
     384
     385  var geonames = jData.geonames;
     386  if (geonames.length > 0) {
     387    var name = geonames[0];
     388    var ll = new LatLng(name.lat,name.lng);
     389    ll.WGS84ToOSGB36();
     390    var en = ll.toOSRef();
     391    var easting = Math.round(en.easting/1000);
     392    var northing = Math.round(en.northing/1000);
     393    gotoLocation(easting, northing, 1);
     394   
     395    document.getElementById('where').value = '';
     396  }
     397  else {
     398    alert("Sorry, can't find that location");
     399  }
     400}
     401
     402
Note: See TracChangeset for help on using the changeset viewer.