From 981e3889da977af1893e3c0030a576120916cc27 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 29 May 2011 22:23:16 +0200 Subject: [PATCH] get rid of special 'area' parameter, use 'query' parameter --- demos/listmap2/js/listmap.js | 12 +++++++----- source/Ox.UI/js/Map/Ox.Map.js | 33 +++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/demos/listmap2/js/listmap.js b/demos/listmap2/js/listmap.js index 40fa68e2..bc493ff1 100644 --- a/demos/listmap2/js/listmap.js +++ b/demos/listmap2/js/listmap.js @@ -75,11 +75,13 @@ Ox.load('Geo', function() { // query, sort, range, area if (Ox.isEmpty(options)) { data = { - items: places.length, - south: 90, - west: 180, - north: -90, - east: -180 + area: { + south: 90, + west: 180, + north: -90, + east: -180 + }, + items: places.length }; places.forEach(function(place) { ['south', 'west', 'north', 'east'].forEach(function(v) { diff --git a/source/Ox.UI/js/Map/Ox.Map.js b/source/Ox.UI/js/Map/Ox.Map.js index 8361b408..30b88411 100644 --- a/source/Ox.UI/js/Map/Ox.Map.js +++ b/source/Ox.UI/js/Map/Ox.Map.js @@ -525,7 +525,7 @@ Ox.Map = function(options, self) { callback(mapBounds); } else { self.options.places({}, function(result) { - callback(getBounds(result.data)); + callback(getBounds(result.data.area)); }); } function getBounds(place) { @@ -736,7 +736,14 @@ Ox.Map = function(options, self) { Ox.print('mapChanged'); var bounds; if (self.boundsChanged) { - bounds = self.map.getBounds(); + var bounds = self.map.getBounds(), + southWest = bounds.getSouthWest(), + northEast = bounds.getNorthEast(), + south = southWest.lat(), + west = southWest.lng(), + north = northEast.lat(), + east = northEast.lng(), + crossesDateline = west > east; if (!self.isAsync) { self.places.sort(function(a, b) { var sort = { @@ -755,17 +762,27 @@ Ox.Map = function(options, self) { }); } else { self.options.places({ - area: { - south: bounds.getSouthWest().lat(), - west: bounds.getSouthWest().lng(), - north: bounds.getNorthEast().lat(), - east: bounds.getNorthEast().lng() - }, keys: [ 'id', 'name', 'geoname', 'countryCode', 'lat', 'lng', 'south', 'west', 'north', 'east', 'editable' ], + query: { + conditions: Ox.merge([ + {key: 'lat', value[south, north], operator: '-'} + ], !crossesDateline ? [ + {key: 'lng', value[west, east], operator: '-'} + ] : [ + { + conditions: [ + {key: 'lng', value: west, operator: '<'}, + {key: 'lng', value: east, operator: '>'} + ], + operator: '|' + } + ]), + operator: '&' + }, range: [0, self.options.maxMarkers], sort: [{key: 'area', operator: '+'}] }, function(result) {