Changeset 616 for trunk


Ignore:
Timestamp:
Dec 16, 2007, 9:48:54 PM (12 years ago)
Author:
Nick Burch
Message:

Fix indents

File:
1 edited

Legend:

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

    r614 r616  
    1414
    1515<script type="text/javascript">
    16     <!--
    17    
    18     var osMap;
    19         var markers;
    20         var url = "/cgi/get-postcodes.fcgi";
    21         var grid = "osgb";
     16<!--
    2217
    23         var successHandler = function(o){
    24           eval(o.responseText);
     18var osMap;
     19var markers;
     20var url = "/cgi/get-postcodes.fcgi";
     21var grid = "osgb";
     22
     23var sources = new Array(1);
     24sources[0] = 'this site';
     25sources[1] = '<a href="http://www.freethepostcode.org/">freethepostcode.org</a>';
     26sources[2] = '<a href="http://www.npemap.org.uk">npemap</a>';
     27
     28var successHandler = function(o){
     29  eval(o.responseText);
     30}
     31
     32var failHander = function(o) {
     33  // Don't do anything
     34  $('spinner').innerHTML = '<p class="error">Problem showing existing data.</p>';
     35}
     36
     37function drawExisting() {
     38        // Clear all our makers
     39        for(var marker in osMap.markers) {
     40                markers.removeMarker(marker);
     41                alert(marker);
     42        }
     43        markers.clearMarkers();
     44
     45        // Only display at zoom levels 8+
     46        if(osMap.zoom < 8) {
     47                return;
    2548        }
    2649
    27         var failHander = function(o) {
    28           // Don't do anything
    29           $('spinner').innerHTML = '<p class="error">Problem showing existing data.</p>';
    30         }
    31    
    32         function drawExisting() {
    33                 // Clear all our makers
    34                 markers.clearMarkers();
     50        var bounds = osMap.calculateBounds();
     51        var params = "mineasting=" + bounds.left + "&maxeasting="  + bounds.right + "&minnorthing=" + bounds.bottom + "&maxnorthing=" + bounds.top + "&grid=" + grid;
     52        $('spinner').innerHTML = '<p>Fetching postcodes, please wait</p>';
    3553
    36                 // Only display at zoom levels 8+
    37                 if(osMap.zoom < 8) {
    38                         return;
    39                 }
     54        var myAjax = new Ajax.Request(url, {
     55                method: 'get',
     56                parameters: params,
     57                onComplete: successHandler,
     58                onFailure: failHander
     59        });
     60}
    4061
    41                 var bounds = osMap.calculateBounds();
    42                 var params = "mineasting=" + bounds.left + "&maxeasting="  + bounds.right + "&minnorthing=" + bounds.bottom + "&maxnorthing=" + bounds.top + "&grid=" + grid;
    43                 $('spinner').innerHTML = '<p>Fetching postcodes, please wait</p>';
     62function addNew(e) {
     63        var en = 
     64                osMap.getLonLatFromViewPortPx( osMap.events.getMousePosition(e) );
     65        var easting = en.lon;
     66        var northing = en.lat;
     67        alert("e=" + easting + " n=" + northing);
     68}
    4469
    45                 var myAjax = new Ajax.Request(url, {
    46                         method: 'get',
    47                         parameters: params,
    48                         onComplete: successHandler,
    49                         onFailure: failHander
    50                 });
    51         }
     70function init()
     71{
     72        osMap = new OpenSpace.Map('map');
     73        osMap.setCenter(new OpenSpace.MapPoint(438760, 114760), 8);
     74       
     75        markers = new OpenLayers.Layer.Markers("Markers");
     76        osMap.addLayer(markers);
    5277
    53         function addNew(e) {
    54                 var en = 
    55                         osMap.getLonLatFromViewPortPx( osMap.events.getMousePosition(e) );
    56                 var easting = en.lon;
    57                 var northing = en.lat;
    58                 alert("e=" + easting + " n=" + northing);
    59         }
    60    
    61     function init()
    62     {
    63         osMap = new OpenSpace.Map('map');
    64         osMap.setCenter(new OpenSpace.MapPoint(438760, 114760), 8);
    65        
    66                 markers = new OpenLayers.Layer.Markers("Markers");
    67         osMap.addLayer(markers);
     78        osMap.events.register("moveend", osMap, drawExisting);
     79        osMap.events.register("zoomend", osMap, drawExisting);
     80        osMap.events.register("click", osMap, addNew);
     81       
     82        drawExisting();
     83}
    6884
    69                 osMap.events.register("moveend", osMap, drawExisting);
    70                 osMap.events.register("zoomend", osMap, drawExisting);
    71                 osMap.events.register("click", osMap, addNew);
    72        
    73                 drawExisting();
    74     }
     85function addMarker(postcode, easting, northing, others ) {
     86        var id = others[0];
     87        var source = others[1];
    7588
    76         function addMarker(postcode, easting, northing, others ) {
    77                 var id = others[0];
    78                 var source = others[1];
    79                 var source_name = ((source == 0 || source == 2) ? 'this site' : '<a href="http://www.freethepostcode.org/">freethepostcode.org</a>');
     89        var pos = new OpenSpace.MapPoint(easting, northing);
     90        var content = "<div><b>Postcode:</b> " + postcode + "<br /><b>Location:</b> " + easting + ", " + northing + "<br /><b>Source:</b> " + sources[source] + "<br /><b>ID:</b> " + id + "</div>";
    8091
    81         var pos = new OpenSpace.MapPoint(easting, northing);
    82                 var content = "<div><b>Postcode:</b> " + postcode + "<br /><b>Location:</b> " + easting + ", " + northing + "<br /><b>Source:</b> " + source_name + "<br /><b>ID:</b> " + id + "</div>";
     92        var marker = osMap.createMarker(pos, null, content);
     93        markers.addMarker(marker);               
     94}
    8395
    84         var marker = osMap.createMarker(pos, null, content);
    85         markers.addMarker(marker);               
    86         }
     96function completeMarkers() {
     97        $('spinner').innerHTML = "&nbsp;";
     98}
    8799
    88         function completeMarkers() {
    89                 $('spinner').innerHTML = "&nbsp;";
    90         }
    91 
    92     // -->
     100// -->
    93101</script>
    94102
Note: See TracChangeset for help on using the changeset viewer.