Ignore:
Timestamp:
Dec 21, 2011, 8:42:40 PM (13 years ago)
Author:
rick
Message:

Permalink custom layers, nice!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/wlheatmap/static/heatmap_extensions.js

    r9782 r9813  
    408408   * Blank parameters are ignored.
    409409   */
    410   function add_filter(lname, filter) {
     410  function add_filter(lname, filter, colour) {
    411411    // setting layer
    412412    OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, {
     
    419419        OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
    420420      },
    421 
    422     CLASS_NAME: "OpenLayers.Layer.Overlay"
     421      colour: colour,
     422      CLASS_NAME: "OpenLayers.Layer.Overlay"
    423423    });
    424424
     
    435435      lname= 'Custom Filter';
    436436    }
    437     add_filter(lname, $("#raw_filter").val());
    438 
    439   });
     437    add_filter(lname, $("#raw_filter").val(), colour);
     438
     439  });
     440
     441  // Parse the parameters
     442  var items = window.location.search.slice(1).split('&');
     443  var params = new Object;
     444  for (var i=0; i < items.length; i++) {
     445    var kv = items[i].split('=');
     446    params[kv[0]] = decodeURIComponent(kv[1]);
     447  }
     448
    440449  init_heatmap();
    441450  init_slider(35,75);
    442451
     452 
    443453  // Initiate the custom filters
    444   var items = window.location.hash.split('#').slice(1);
    445   for (var i=0; i < items.length; i++) {
    446     var y = items[i].split('!');
    447     var type = y[0];
    448     if ( type == 'filter') {
    449       add_filter(y[1], y[2]);
    450     } else if ( type == 'focus') {
    451       var lonLat = new OpenLayers.LonLat(y[1], y[2]).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
    452       map.setCenter (lonLat, y[3]);
    453     }
    454   }
     454  if (params['layercount']) {
     455    for (var i=1; i <= params['layercount']; i++) {
     456      add_filter(params['layername' + i], params['layerfilter' + i], params['layercolour' + i]);
     457    }
     458  }
     459  var pl = map.getControlsByClass('OpenLayers.Control.Permalink');
     460  pl.updateLink();
    455461});
Note: See TracChangeset for help on using the changeset viewer.