Changeset 525 for trunk


Ignore:
Timestamp:
Apr 10, 2007, 8:01:06 PM (13 years ago)
Author:
Nick Burch
Message:

Support finding by grid reference, and by lat+long

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/static/find.js

    r488 r525  
    1313  var request;
    1414  if(where.length > 0) {
    15     if(where.toUpperCase().match(/^([A-Z]+\d+[A-Z]?)\s*(\d[A-Z][A-Z])?$/)) {
     15    // Only supports 6 fig grid references for now
     16    if(where.toUpperCase().match(/^([HNOST]\w\d{6})$/)) {
     17      var osref = getOSRefFromSixFigureReference(where.toUpperCase());
     18      var easting = Math.round(osref.easting/1000);
     19      var northing = Math.round(osref.northing/1000);
     20      if(typeof urchinTracker == 'function') urchinTracker('/ngrSearch');
     21      gotoLocation(easting,northing,1);
     22    }
     23    else if(where.toUpperCase().match(/^([A-Z]+\d+[A-Z]?)\s*(\d[A-Z][A-Z])?$/)) {
    1624      request = "/cgi/geocoder.fcgi?postcode=" + encodeURIComponent(where) + "&callback=postcodeLoc&format=js";
    1725      if(typeof urchinTracker == 'function') urchinTracker('/postcodeSearch');
    1826
     27    }
     28    else if(where.match(/^([45]\d\.?\d*)[\s,]+(\-?\d+\.?\d*)$/)) {
     29      // 0 is whole string, 1 is 1st bracket, 2 is 2nd bracket
     30      ll = where.match(/^([45]\d\.?\d*)[\s,]+(\-?\d+\.?\d*)$/);
     31      if(typeof urchinTracker == 'function') urchinTracker('/latlongSearch');
     32      gotoLatLong(ll[1],ll[2],1);
    1933    }
    2034    else {
Note: See TracChangeset for help on using the changeset viewer.