Changeset 9813 for src/django_gheat/wlheatmap
- Timestamp:
- Dec 21, 2011, 8:42:40 PM (13 years ago)
- Location:
- src/django_gheat/wlheatmap/static
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/wlheatmap/static/heatmap.js
r9811 r9813 21 21 new OpenLayers.Control.Navigation(), 22 22 new OpenLayers.Control.Permalink({ 23 anchor : true,23 anchor : false, 24 24 createParams: function(center, zoom, layers) { 25 25 center = center || this.map.getCenter(); … … 64 64 // Update permalink URL to reflect new location and filters 65 65 layerid = 0; 66 for (var i=1, len=layers.length; i < len; i++) { 66 // First two and last one should be ignored 67 for (var i=4, len=layers.length; i < len; i++) { 67 68 var layer = layers[i]; 68 69 if ($.isArray(layer.url)) { … … 73 74 var filter = url.split('?')[1]; 74 75 layerid += 1; 75 params['layername' + i] = layer.name; 76 params['layerfilter' + i] = filter; 76 params['layername' + layerid] = layer.name; 77 params['layercolour' + layerid] = layer.colour; 78 params['layerfilter' + layerid] = filter; 77 79 } 78 80 params['layercount'] = layerid; 79 81 } 80 82 return params; 81 } 83 }, 84 draw: function() { 85 OpenLayers.Control.prototype.draw.apply(this, arguments); 86 87 if (!this.element && !this.anchor) { 88 this.element = document.createElement("a"); 89 this.element.innerHTML = OpenLayers.i18n("Permalink"); 90 this.element.href=""; 91 this.div.appendChild(this.element); 92 } 93 this.map.events.on({ 94 'moveend': this.updateLink, 95 'changelayer': this.updateLink, 96 'addlayer': this.updateLink, 97 'removelayer': this.updateLink, 98 'changebaselayer': this.updateLink, 99 scope: this 100 }); 101 102 // Make it so there is at least a link even though the map may not have 103 // moved yet. 104 this.updateLink(); 105 106 return this.div; 107 }, 82 108 }), 83 109 new OpenLayers.Control.PanZoomBar(), -
src/django_gheat/wlheatmap/static/heatmap_extensions.js
r9782 r9813 408 408 * Blank parameters are ignored. 409 409 */ 410 function add_filter(lname, filter ) {410 function add_filter(lname, filter, colour) { 411 411 // setting layer 412 412 OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, { … … 419 419 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); 420 420 }, 421 422 CLASS_NAME: "OpenLayers.Layer.Overlay"421 colour: colour, 422 CLASS_NAME: "OpenLayers.Layer.Overlay" 423 423 }); 424 424 … … 435 435 lname= 'Custom Filter'; 436 436 } 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 440 449 init_heatmap(); 441 450 init_slider(35,75); 442 451 452 443 453 // 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(); 455 461 });
Note:
See TracChangeset
for help on using the changeset viewer.