Prioritize tile loading around mouse position
This commit is contained in:
@@ -242,6 +242,12 @@ ol.Map = function(mapOptions) {
|
|||||||
goog.events.listen(this.viewportSizeMonitor_, goog.events.EventType.RESIZE,
|
goog.events.listen(this.viewportSizeMonitor_, goog.events.EventType.RESIZE,
|
||||||
this.handleBrowserWindowResize, false, this);
|
this.handleBrowserWindowResize, false, this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Coordinate}
|
||||||
|
*/
|
||||||
|
this.focus_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<ol.PreRenderFunction>}
|
* @type {Array.<ol.PreRenderFunction>}
|
||||||
@@ -487,9 +493,10 @@ ol.Map.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter) {
|
|||||||
if (!frameState.wantedTiles[tileSourceKey][coordKey]) {
|
if (!frameState.wantedTiles[tileSourceKey][coordKey]) {
|
||||||
return ol.TileQueue.DROP;
|
return ol.TileQueue.DROP;
|
||||||
}
|
}
|
||||||
var center = frameState.view2DState.center;
|
var focus = goog.isNull(this.focus_) ?
|
||||||
var deltaX = tileCenter.x - center.x;
|
frameState.view2DState.center : this.focus_;
|
||||||
var deltaY = tileCenter.y - center.y;
|
var deltaX = tileCenter.x - focus.x;
|
||||||
|
var deltaY = tileCenter.y - focus.y;
|
||||||
return deltaX * deltaX + deltaY * deltaY;
|
return deltaX * deltaX + deltaY * deltaY;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -502,6 +509,11 @@ ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
|||||||
var type = opt_type || browserEvent.type;
|
var type = opt_type || browserEvent.type;
|
||||||
var mapBrowserEvent = new ol.MapBrowserEvent(type, this, browserEvent);
|
var mapBrowserEvent = new ol.MapBrowserEvent(type, this, browserEvent);
|
||||||
this.handleMapBrowserEvent(mapBrowserEvent);
|
this.handleMapBrowserEvent(mapBrowserEvent);
|
||||||
|
if (type == goog.events.EventType.MOUSEOUT) {
|
||||||
|
this.focus_ = null;
|
||||||
|
} else {
|
||||||
|
this.focus_ = mapBrowserEvent.getCoordinate();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user