forked from 0x2620/oxjs
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
|
// query, sort, range, area
|
||||||
if (Ox.isEmpty(options)) {
|
if (Ox.isEmpty(options)) {
|
||||||
data = {
|
data = {
|
||||||
items: places.length,
|
area: {
|
||||||
south: 90,
|
south: 90,
|
||||||
west: 180,
|
west: 180,
|
||||||
north: -90,
|
north: -90,
|
||||||
east: -180
|
east: -180
|
||||||
|
},
|
||||||
|
items: places.length
|
||||||
};
|
};
|
||||||
places.forEach(function(place) {
|
places.forEach(function(place) {
|
||||||
['south', 'west', 'north', 'east'].forEach(function(v) {
|
['south', 'west', 'north', 'east'].forEach(function(v) {
|
||||||
|
|
|
||||||
|
|
@ -525,7 +525,7 @@ Ox.Map = function(options, self) {
|
||||||
callback(mapBounds);
|
callback(mapBounds);
|
||||||
} else {
|
} else {
|
||||||
self.options.places({}, function(result) {
|
self.options.places({}, function(result) {
|
||||||
callback(getBounds(result.data));
|
callback(getBounds(result.data.area));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getBounds(place) {
|
function getBounds(place) {
|
||||||
|
|
@ -736,7 +736,14 @@ Ox.Map = function(options, self) {
|
||||||
Ox.print('mapChanged');
|
Ox.print('mapChanged');
|
||||||
var bounds;
|
var bounds;
|
||||||
if (self.boundsChanged) {
|
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) {
|
if (!self.isAsync) {
|
||||||
self.places.sort(function(a, b) {
|
self.places.sort(function(a, b) {
|
||||||
var sort = {
|
var sort = {
|
||||||
|
|
@ -755,17 +762,27 @@ Ox.Map = function(options, self) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.options.places({
|
self.options.places({
|
||||||
area: {
|
|
||||||
south: bounds.getSouthWest().lat(),
|
|
||||||
west: bounds.getSouthWest().lng(),
|
|
||||||
north: bounds.getNorthEast().lat(),
|
|
||||||
east: bounds.getNorthEast().lng()
|
|
||||||
},
|
|
||||||
keys: [
|
keys: [
|
||||||
'id', 'name', 'geoname', 'countryCode',
|
'id', 'name', 'geoname', 'countryCode',
|
||||||
'lat', 'lng', 'south', 'west', 'north', 'east',
|
'lat', 'lng', 'south', 'west', 'north', 'east',
|
||||||
'editable'
|
'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],
|
range: [0, self.options.maxMarkers],
|
||||||
sort: [{key: 'area', operator: '+'}]
|
sort: [{key: 'area', operator: '+'}]
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue