get rid of special 'area' parameter, use 'query' parameter
This commit is contained in:
parent
4eb1b99c76
commit
981e3889da
2 changed files with 32 additions and 13 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue