Changeset 18


Ignore:
Timestamp:
Oct 11, 2006, 4:32:41 PM (13 years ago)
Author:
David Sheldon
Message:

Use the yahoo dom library to find the X,Y of the tiles, much better.

Location:
trunk/npemap.org.uk/static/tiles
Files:
2 edited

Legend:

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

    r16 r18  
    55    </head>
    66<body onload="initializePage(); initialGrid(); go();"  onResize="window.location.href = window.location.href;">
     7<!-- Yahoo functions -->
     8<script src="yahoo.js"></script>
     9<script src="dom.js"></script>
     10<!-- Our functions -->
    711<script src="mapTiles.js"></script>
    812<script src="postcode.js"></script>
  • trunk/npemap.org.uk/static/tiles/postcode.js

    r16 r18  
    1515        var y = e.pageY - mapContainerElement.offsetTop;
    1616                                var img = e.target;
    17                                 var tileX = e.pageX - img.offsetLeft;
    18                                 var tileY = e.pageY - img.offsetTop;
     17                                var imgPos = YAHOO.util.Dom.getXY(img);
     18                                var tileX = e.pageX - imgPos[0];
     19                                var tileY = e.pageY - imgPos[1];
    1920                                // Tiles are eee/nnn.jpg
    2021                                var tile = img.src.substring( img.src.lastIndexOf("/") - 3 );
     
    2324                               
    2425                                var easting = baseEasting + ('000' + Math.round((tileX/img.offsetWidth)*1000)).substr(-3)
    25                                 var northing = baseNorthing + ('000' + Math.round(((tileY/img.offsetHeight))*1000)).substr(-3)
     26                                var northing = baseNorthing + ('000' + Math.round((1-(tileY/img.offsetHeight))*1000)).substr(-3)
    2627
    2728                               
Note: See TracChangeset for help on using the changeset viewer.