Skip to content

Commit

Permalink
cf brutasse#37 - Uncouple image tiles and geojson giles loading
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Oct 3, 2012
1 parent b0c33a8 commit 930f734
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions djangopeople/djangopeople/static/djangopeople/js/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function greenIconImage() {
L.TileLayer.ClusteredGeoJSONTile = L.TileLayer.extend({

initClusterMarker: function (map) {
this._geojsonTilesToLoad = 0;
var polygonOptions = {
fillColor: "#ab5603",
color: "#ab5603",
Expand Down Expand Up @@ -84,8 +85,8 @@ L.TileLayer.ClusteredGeoJSONTile = L.TileLayer.extend({
self.initClusterMarker(map);
});
this.on({
'loading': this.initTmpLayer,
'load': this.commitTmpLayer
'geojsonloadinit': this.initTmpLayer,
'geojsonloadend': this.commitTmpLayer
});
L.TileLayer.prototype.onAdd.call(this, map);
},
Expand All @@ -104,9 +105,20 @@ L.TileLayer.ClusteredGeoJSONTile = L.TileLayer.extend({
y: y
});
var self = this;
if(!this._geojsonTilesToLoad) {
this.fire("geojsonloadinit")
}
// Register that this tile is not yet loaded
this._geojsonTilesToLoad++;
$.getJSON(dataUrl, function (data) {
DATA = data;
self.tmpLayer.addData(data);
// Tile loaded
self._geojsonTilesToLoad--;
if(!self._geojsonTilesToLoad) {
// No more tiles to load
self.fire("geojsonloadend")
}
});
}

Expand Down

0 comments on commit 930f734

Please sign in to comment.