Skip to content

Commit

Permalink
updating tests. Pushing fix for addChildLayers
Browse files Browse the repository at this point in the history
  • Loading branch information
apollolm committed Oct 2, 2014
1 parent f39d10f commit be660ea
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 557 deletions.
885 changes: 346 additions & 539 deletions dist/Leaflet.MapboxVectorTile.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dist/Leaflet.MapboxVectorTile.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "leaflet-mapbox-vector-tile",
"version": "0.0.6",
"version": "0.0.8",
"description": "A Leaflet Plugin that renders Mapbox Vector Tiles on HTML5 Canvas.",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/MVTSource.js
Expand Up @@ -322,7 +322,7 @@ module.exports = L.TileLayer.MVTSource = L.TileLayer.Canvas.extend({
},

addChildLayers: function(map) {

var self = this;
if(self.options.visibleLayers.length > 0){
//only let thru the layers listed in the visibleLayers array
for(var i=0; i < self.options.visibleLayers.length; i++){
Expand Down
2 changes: 0 additions & 2 deletions test.html

This file was deleted.

2 changes: 2 additions & 0 deletions test/visibletests/confetti_test.html
@@ -0,0 +1,2 @@
<script src="../../lib/Leaflet/leaflet-0.7.3/leaflet-src.js"></script>
<script src="confetti_test.js"></script>
37 changes: 30 additions & 7 deletions test.js → test/visibletests/confetti_test.js
Expand Up @@ -10909,6 +10909,7 @@ MVTFeature.prototype.toggle = function() {

MVTFeature.prototype.select = function() {
this.selected = true;
this.mvtSource.featureSelected(this);
redrawTiles(this);
var linkedFeature = this.linkedFeature();
if (linkedFeature && linkedFeature.staticLabel && !linkedFeature.staticLabel.selected) {
Expand Down Expand Up @@ -11659,7 +11660,7 @@ module.exports = L.TileLayer.MVTSource = L.TileLayer.Canvas.extend({
var buf = new Protobuf(arrayBuffer);
var vt = new VectorTile(buf);
//Check the current map layer zoom. If fast zooming is occurring, then short circuit tiles that are for a different zoom level than we're currently on.
if(self._map.getZoom() != ctx.zoom) {
if(self.map && self.map.getZoom() != ctx.zoom) {
console.log("Fetched tile for zoom level " + ctx.zoom + ". Map is at zoom level " + self._map.getZoom());
return;
}
Expand Down Expand Up @@ -11784,11 +11785,25 @@ module.exports = L.TileLayer.MVTSource = L.TileLayer.Canvas.extend({
},

addChildLayers: function(map) {
for (var key in this.layers) {
var layer = this.layers[key];
// layer is set to visible and is not already on map
if (layer.visible && !layer._map) {
map.addLayer(layer);
var self = this;
if(self.options.visibleLayers.length > 0){
//only let thru the layers listed in the visibleLayers array
for(var i=0; i < self.options.visibleLayers.length; i++){
var layerName = self.options.visibleLayers[i];
var layer = this.layers[layerName];
if(layer){
//Proceed with parsing
map.addLayer(layer);
}
}
}else{
//Add all layers
for (var key in this.layers) {
var layer = this.layers[key];
// layer is set to visible and is not already on map
if (!layer._map) {
map.addLayer(layer);
}
}
}
},
Expand Down Expand Up @@ -11850,9 +11865,17 @@ module.exports = L.TileLayer.MVTSource = L.TileLayer.Canvas.extend({
layer.clearTileFeatureHash();
}
}
},


featureSelected: function(mvtFeature) {
if (this.options.mutexToggle) {
if (this._selectedFeature) {
this._selectedFeature.deselect();
}
this._selectedFeature = mvtFeature;
}
}

});


Expand Down

0 comments on commit be660ea

Please sign in to comment.