Changeset 9177 for src/django_gheat


Ignore:
Timestamp:
May 11, 2011, 12:17:18 PM (14 years ago)
Author:
dennisw
Message:

Progress on showing nodes around mouse when hovering over map.
Right now, it returns some placeholder json object on click.

Next steps: replace placeholder with real data, print readable lines instead of [object Object], and get mouse boundaries.

Location:
src/django_gheat/website
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/website/static/heatmap.js

    r9175 r9177  
    2424                var lonlat = map.getLonLatFromPixel(pixel);
    2525                var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(lonlat.lon, lonlat.lat);
    26                 loadXMLDoc(mousepos);
    27                 //var url = "/website/wlnode/" + mousepos.lat + "," + mousepos.lon;
    28                 //window.location = url;
     26                loadNodeList(mousepos);
    2927        }
    3028
     
    3432        map.addLayer(layerHeatmap);
    3533
    36         layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: false});
     34        layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: true});
    3735        map.addLayer(layerHeatmap2);
    3836
     
    4846}
    4947
    50 function loadXMLDoc(mousepos)
    51 {
    52 var xmlhttp;
    53 var txt,xx,x,i;
    54 if (window.XMLHttpRequest)
    55   {// code for IE7+, Firefox, Chrome, Opera, Safari
    56   xmlhttp=new XMLHttpRequest();
     48function loadNodeList(mousepos){
     49  var nodelist;
     50  if (window.XMLHttpRequest){
     51    // code for IE7+, Firefox, Chrome, Opera, Safari
     52    nodelist=new XMLHttpRequest();
    5753  }
    58 else
    59   {// code for IE6, IE5
    60   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     54  else{
     55    // code for IE6, IE5
     56    nodelist=new ActiveXObject("Microsoft.XMLHTTP");
    6157  }
    6258
    63 
    64 xmlhttp.onreadystatechange=function()
    65   {
    66   if (xmlhttp.readyState==4 && xmlhttp.status==200)
    67     {
    68     txt="";
    69     x=xmlhttp.responseXML.documentElement.getElementsByTagName("CD");
    70     for (i=0;i<x.length;i++)
    71       {
    72       xx=x[i].getElementsByTagName("ARTIST");
    73       txt=txt + xx[0].firstChild.nodeValue + "<br>";
    74       }
    75     document.getElementById('nodelist').innerHTML=txt;
     59  nodelist.onreadystatechange=function(){
     60    if (nodelist.readyState==4 && nodelist.status==200){
     61      txt=eval("("+nodelist.responseText+")")
     62      document.getElementById('nodelist').innerHTML=txt;
    7663    }
    7764  }
    78 xmlhttp.open("POST","/static/test.xml",true);
    79 //xmlhttp.open("POST","/website/lat=" + mousepos.lat + "&lon=" + mousepos.lon,true);
    80 xmlhttp.send();
     65
     66  nodelist.open("GET","/website/nodelist/" + mousepos.lat + "," + mousepos.lon,true);
     67  nodelist.send();
    8168}
  • src/django_gheat/website/templates/home.html

    r9175 r9177  
    1717        <h1>Info</h1><br />
    1818        Info
    19         <div id="nodelist"><h2>Let AJAX change this text</h2></div>
    20         <button type="button" onclick="loadXMLDoc()">Change Content</button>
     19        <div id="nodelist"></div>
    2120      </div>
    2221      <div id="footer"> <a href="http://www.wirelessleiden.nl/">wirelessleiden.nl</a> </div>
  • src/django_gheat/website/urls.py

    r9147 r9177  
    1919       ),
    2020    )
     21
     22urlpatterns += patterns('website.nodelist',
     23    url(
     24        regex = r'^nodelist/(?P<lat>[0-9.]+),(?P<lon>[0-9.]+)$',
     25        view = 'serve_nodelist',
     26        name = 'serve_nodelist',
     27       ),
     28    )
Note: See TracChangeset for help on using the changeset viewer.