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,
zoom: 11
},
on: {
'resize': mapResize,
'zoomend': mapZoomend,
'moveend': mapMoveend,
},
css: {
width: '100%',
height: '100%'

View file

@ -174,6 +174,18 @@ define([
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() {

View file

@ -142,11 +142,13 @@
dirty : true,
updateId : 0,
update : function(id) {
var that = this;
if (this.updateId != id)
return;
if (this.dirty) {
// this.dirty = false;
this.dirty = false;
var bounds = this._map.getBounds();
// radius in NM
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 that = this;
var jqxhr = $.get(url).done(function(data) {
if (that.updateId == id) {
that.clearLayers();