remove entities outside the map request bounds before processing any requests

prevent the selected portal from being removed
re-select the selected portal - should refresh the side bar when data changes
This commit is contained in:
Jon Atkins
2013-08-30 00:34:07 +01:00
parent 4c343386e4
commit de3d05fe95
2 changed files with 57 additions and 24 deletions

View File

@ -132,19 +132,26 @@ window.MapDataRequest.prototype.refresh = function() {
var zoom = getPortalDataZoom();
var minPortalLevel = getMinPortalLevelForZoom(zoom);
window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom});
this.render.startRenderPass(bounds);
this.render.clearPortalsBelowLevel(minPortalLevel);
console.log('requesting data tiles at zoom '+zoom+' (L'+minPortalLevel+'+ portals), map zoom is '+map.getZoom());
var x1 = lngToTile(bounds.getWest(), zoom);
var x2 = lngToTile(bounds.getEast(), zoom);
var y1 = latToTile(bounds.getNorth(), zoom);
var y2 = latToTile(bounds.getSouth(), zoom);
window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom});
this.render.startRenderPass();
this.render.clearPortalsBelowLevel(minPortalLevel);
// calculate the full bounds for the data - including the part of the tiles off the screen edge
var dataBounds = L.latLngBounds([
[tileToLat(y2+1,zoom), tileToLng(x1,zoom)],
[tileToLat(y1,zoom), tileToLng(x2+1,zoom)]
]);
this.render.clearEntitiesOutsideBounds(dataBounds);
console.log('requesting data tiles at zoom '+zoom+' (L'+minPortalLevel+'+ portals), map zoom is '+map.getZoom());
this.cachedTileCount = 0;
this.requestedTileCount = 0;
this.successTileCount = 0;