diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index ea892301..5ccf3936 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -9332,6 +9332,7 @@ requires editable: false, height: 256, labels: false, + markers: 100, places: [], selected: null, statusbar: false, @@ -9828,7 +9829,7 @@ requires self.options.places.forEach(function(place, i) { self.places[i] = new Ox.MapPlace(Ox.extend({ map: that - }, place)).add(); + }, place))/*.add()*/; }); google.maps.event.trigger(self.map, 'resize'); that.gainFocus(); @@ -9838,27 +9839,24 @@ requires function mapChanged() { // gets called after panning or zooming Ox.print('mapChanged'); - var bounds, places + var bounds; if (self.boundsChanged) { - /* bounds = self.map.getBounds(); - places = Ox.clone(self.places).filter(function(place) { - return bounds.contains(place.center); - }); - if (places.length > 100) { - places.sort(function(a, b) { - return a.size < b.size ? 1 : (a.size > b.size ? -1 : 0); - }); - } - self.places.forEach(function(place) { - place.remove(); - }); - places.forEach(function(place, i) { - if (i < 100) { + self.places.sort(function(a, b) { + var sort = { + a: a.selected ? Infinity : + (bounds.contains(a.center) ? a.size : -Infinity), + b: b.selected ? Infinity : + (bounds.contains(b.center) ? b.size : -Infinity), + }; + return sort.b - sort.a; + }).forEach(function(place, i) { + if (i < self.options.markers && !place.visible) { place.add(); + } else if (i >= self.options.markers && place.visible) { + place.remove(); } }); - */ self.boundsChanged = false; } if (self.centerChanged) { @@ -10216,6 +10214,7 @@ requires selected: false, south: 0, type: [], + visible: false, west: 0 }, options), that = this; @@ -10272,6 +10271,7 @@ requires that.add = function() { Ox.print('MapPlace add', that) + that.visible = true; that.marker.add(); return that; }; @@ -10317,6 +10317,7 @@ requires Ox.print('MapPlace remove', that) that.editing && that.submit(); that.selected && that.deselect(); + that.visible = false; that.marker.remove(); return that; };