1
0
Fork 0

Phi: don't query navdb until map moved or resized

This commit is contained in:
Torsten Dreyer 2015-03-09 13:42:07 +01:00
parent 7b53516a96
commit 65d16e358d
3 changed files with 20 additions and 2 deletions

View file

@ -5,6 +5,11 @@
attributionControl: true, attributionControl: true,
zoom: 11 zoom: 11
}, },
on: {
'resize': mapResize,
'zoomend': mapZoomend,
'moveend': mapMoveend,
},
css: { css: {
width: '100%', width: '100%',
height: '100%' height: '100%'

View file

@ -174,6 +174,18 @@ define([
attribution : '&copy; <a target="_blank" href="http://openweathermap.org/">open weather map</a>', attribution : '&copy; <a target="_blank" href="http://openweathermap.org/">open weather map</a>',
}), }),
} }
self.mapResize = function(a,b) {
self.overlays.NavDB.invalidate();
}
self.mapZoomend = function() {
self.overlays.NavDB.invalidate();
}
self.mapMoveend = function() {
self.overlays.NavDB.invalidate();
}
} }
ViewModel.prototype.dispose = function() { ViewModel.prototype.dispose = function() {

View file

@ -142,11 +142,13 @@
dirty : true, dirty : true,
updateId : 0, updateId : 0,
update : function(id) { update : function(id) {
var that = this;
if (this.updateId != id) if (this.updateId != id)
return; return;
if (this.dirty) { if (this.dirty) {
// this.dirty = false; this.dirty = false;
var bounds = this._map.getBounds(); var bounds = this._map.getBounds();
// radius in NM // radius in NM
var radius = bounds.getSouthWest().distanceTo(bounds.getNorthEast()) / 3704; var radius = bounds.getSouthWest().distanceTo(bounds.getNorthEast()) / 3704;
@ -168,7 +170,6 @@
var url = "/navdb?q=findWithinRange&type=" + filter + "&range=" + radius + "&lat=" + lat + "&lon=" + lon; var url = "/navdb?q=findWithinRange&type=" + filter + "&range=" + radius + "&lat=" + lat + "&lon=" + lon;
var that = this;
var jqxhr = $.get(url).done(function(data) { var jqxhr = $.get(url).done(function(data) {
if (that.updateId == id) { if (that.updateId == id) {
that.clearLayers(); that.clearLayers();