Changeset 48


Ignore:
Timestamp:
Oct 15, 2006, 6:02:45 PM (13 years ago)
Author:
David Sheldon
Message:

Show existing Postcodes on the map.

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

Legend:

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

    r42 r48  
    44        <link rel="stylesheet" type="text/css" href="grid.css">
    55    </head>
    6 <body onload="initializePage(); doResize(); go();"  onResize="doResize() ">
     6<body onload="initializePage(); go();doResize(); "  onResize="doResize() ">
    77<!-- Yahoo functions -->
    88<script src="yahoo.js"></script>
    99<script src="dom.js"></script>
     10<script src="connection.js"></script>
    1011<!-- Our functions -->
    1112<script src="mapTiles.js"></script>
  • trunk/npemap.org.uk/static/tiles/mapTiles.js

    r25 r48  
    119119                for(var y=1; y<=sizeGridY; y++) {
    120120            // Update the table using the array data from position 0,0.
    121             tileX = ('000'+(x+offsetGridX-Math.round(sizeGridX/2))).substr(-3)
    122             tileY = ('000'+(y+offsetGridY-Math.round(sizeGridY/2))).substr(-3)
    123             document.getElementById('element' + x + '.' + y).src = prefix+tileX+'/'+ tileY + '.jpg'
     121            tileX = ('000'+(x+offsetGridX-Math.round(sizeGridX/2))).substr(-3);
     122            tileY = ('000'+(y+offsetGridY-Math.round(sizeGridY/2))).substr(-3);
     123            document.getElementById('element' + x + '.' + y).src = prefix+tileX+'/'+ tileY + '.jpg';
    124124        }
    125125    }
    126 
     126  minEasting = (offsetGridX-Math.round(sizeGridX/2))+1;
     127  minNorthing= (offsetGridY-Math.round(sizeGridY/2))+1;
     128  maxEasting = minEasting + sizeGridX;
     129  maxNorthing= minNorthing + sizeGridY;
     130
     131  drawExisting();
    127132        updatePermalink();
    128133}
    129134
    130 function updatePermalink(tileX,tileY) {
     135function drawExisting() {
     136  var url = "../../cgi/get-postcodes.fcgi";
     137  url += "?mineasting=" + minEasting + "000&maxeasting="  + maxEasting + "000&minnorthing=" + minNorthing + "000&maxnorthing=" + maxNorthing+"000";
     138  var callback = {
     139    success: successHandler ,
     140    failure: failHander
     141    }
     142 
     143  removeMarkers();
     144  YAHOO.util.Connect.asyncRequest('GET', url, callback); 
     145}
     146
     147var successHandler = function(o){
     148  eval(o.responseText); 
     149}
     150
     151var failHander = function(o) {
     152  alert("Failed");
     153}
     154
     155var markers = new Array();
     156
     157function removeMarkers() {
     158  var pageElement = document.getElementById('main_page');
     159  for(var i=0; i<markers.length; i=i+1) {
     160    pageElement.removeChild(markers[i]);
     161  }
     162  markers = new Array();
     163}
     164
     165function addMarker(postcode, easting, northing) {
     166  var markerXOffset = 4;
     167  var markerYOffset = 11;
     168
     169  var newMarker = document.createElement('div');
     170  newMarker.innerHTML = "<img src='../images/green-marker.gif' />";
     171  newMarker.style.position = 'absolute';
     172  document.getElementById('main_page').appendChild(newMarker);
     173
     174  markers[markers.length] = newMarker;
     175
     176  var x = ((easting / 1000) - minEasting) * tileWidth;
     177  var y = ((northing / 1000) - minNorthing) * tileHeight;
     178  var bl = YAHOO.util.Dom.getXY('element1.1');
     179  var bottom = bl[1] + tileHeight;
     180
     181  YAHOO.util.Dom.setXY(newMarker, [bl[0]+x-markerXOffset, bottom- (y+markerYOffset)]);
     182}
     183
     184
     185function updatePermalink() {
    131186        document.getElementById("permalink").href = "?" + offsetGridX + "," + offsetGridY + "," + zoomLevel;
    132187}
  • trunk/npemap.org.uk/static/tiles/postcode.js

    r42 r48  
    2929        markerElement.style.visibility = 'visible';
    3030       
    31         YAHOO.util.Dom.setXY(postcodeFormElement, [(x-50) < 0 ? 0:(x-50), (y-180) < 0 ? (y+10):(y-180)]);
     31        YAHOO.util.Dom.setXY(postcodeFormElement, [Math.max(0, (x-50)), (y-180) < 0 ? (y+10):(y-180)]);
    3232        postcodeFormElement.style.display = 'block';
    3333                                locationElement.innerHTML = easting + ', ' + northing
Note: See TracChangeset for help on using the changeset viewer.