Ignore:
Timestamp:
Aug 28, 2011, 3:08:38 PM (13 years ago)
Author:
rick
Message:
  • Fixed the color and the URL locations references, to be more dynamic/logical.
  • Make the Organization do a catchall for the time beeing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/wlheatmap/templates/js/LayerBase.js

    r9592 r9596  
    184184    initialize: function(name, options) {
    185185        var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
    186           '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__organization__name=WirelessLeiden');
     186          '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__organization__name__startswith=Wireless');
    187187        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
    188188        var newArguments = [name, url, options];
     
    207207  CLASS_NAME: "OpenLayers.Layer.Overlay"
    208208});
     209
     210var foo;
     211
     212// create the layer styleMap by giving the default style a context
     213var context = {
     214    getSize: function(feature) {
     215      var resolution = map.getResolution();
     216      var scale = map.getZoom();
     217      var base = 1;
     218      if (scale > 16) {
     219        base = 5;
     220      } else if (scale > 14) {
     221        base = 20;
     222      } else {
     223        base = 50;
     224      }
     225      return (base / map.getResolution());
     226    },
     227    getColor: function(feature) {
     228      return feature.attributes.color;
     229
     230    }
     231};
     232var template = {
     233    pointRadius: "${getSize}", // using context.getSize(feature)
     234    fillColor: "${getColor}", // using context.getColor(feature)
     235    strokeWidth: 0.5,
     236};
     237var nodesStyle = new OpenLayers.Style(template, {context: context});
     238
     239OpenLayers.Layer.GML.NodesOverlay = OpenLayers.Class(OpenLayers.Layer.GML, {
     240    initialize: function(name, options) {
     241        var url = "{% url wlheatmap.feature.nodes_json %}";
     242        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
     243        var newArguments = [name, url, options];
     244        OpenLayers.Layer.GML.prototype.initialize.apply(this, newArguments);
     245    },
     246    colour: '0,255,0',
     247    projection: new OpenLayers.Projection("EPSG:4326"),
     248    styleMap: new OpenLayers.StyleMap(nodesStyle),
     249    format: OpenLayers.Format.GeoJSON,
     250    CLASS_NAME: "OpenLayers.Layer.Overlay"
     251});
     252
Note: See TracChangeset for help on using the changeset viewer.