Changeset 143


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

Tidy up the code a bit.

File:
1 edited

Legend:

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

    r133 r143  
    5454
    5555<script type="text/javascript">
     56var ROOTURL = ".";
     57
    5658var xOffset = 62;
    5759
     
    8183    var easting = Math.round(en.easting/1000);
    8284    var northing = Math.round(en.northing/1000);
    83     window.location = "tiles/map.html#" + easting + "," + northing + ",1";
     85    window.location = urlFor(easting, northing, 1);
    8486  }
    8587  else {
     
    9698  var imgPos = YAHOO.util.Dom.getXY(img);
    9799
    98         var x = xOffset + YAHOO.util.Event.getPageX(e) - imgPos[0];
    99         var y = img.height-(YAHOO.util.Event.getPageY(e) - imgPos[1]);
     100        var x = (xOffset + YAHOO.util.Event.getPageX(e) - imgPos[0]) * 2;
     101        var y = (img.height-(YAHOO.util.Event.getPageY(e) - imgPos[1])) * 2;
    100102
    101         var s6x = Math.round(x/3);
    102         var s6y = Math.round(y/3);
    103 
    104         window.location=("tiles/map.html#" + s6x + "," + s6y + ",3");
     103        window.location=(urlFor(x, y, 1));
    105104
    106105        YAHOO.util.Event.stopEvent(e);
    107106}
    108107
    109   YAHOO.util.Event.addListener("link", "click", click);
     108YAHOO.util.Event.addListener("link", "click", click);
     109
     110var zooms = new Array(1);
     111zooms[1] = 1;
     112zooms[2] = 3;
     113zooms[3] = 6;
     114
     115function urlFor(easting, northing, zoom) {
     116  var x= easting / zooms[zoom];
     117  var y= northing/ zooms[zoom];
     118  return ROOTURL + "/tiles/map.html#" +  x + "," + y +","+zoom;
     119}
    110120
    111121</script>
Note: See TracChangeset for help on using the changeset viewer.