1
0
Fork 0
forked from 0x2620/oxjs

make map in async listmap async

This commit is contained in:
rolux 2011-05-29 14:22:54 +02:00
commit 93408b0b4d
4 changed files with 167 additions and 135 deletions

View file

@ -23,7 +23,7 @@ Ox.load('Geo', function() {
lngSize = area * Ox.getDegreesPerMeter(city.latitude);
return {
alternativeNames: [],
area: city.population * 100,
area: area,
countryCode: countryCode,
editable: true,
flag: countryCode,
@ -71,7 +71,10 @@ Ox.load('Geo', function() {
} else {
data.items = places;
if (options.query) {
// only case is key: 'id', value: ..., operator: '='
data.items = data.items.filter(function(place) {
return place[options.query.key] == options.query.value;
});
}
if (options.area) {
data.items = data.items.filter(function(place) {
@ -80,30 +83,35 @@ Ox.load('Geo', function() {
&& place.lat < options.area.north
&& place.lng > options.area.west
&& place.lng < options.area.east;
}).sort(function(a, b) {
return b.area - a.area;
}).filter(function(place, i) {
return i < 100;
});
} else {
data.items.sort(function(a, b) {
if (options.sort[0].key == 'geoname') {
aValue = a.geonameSort;
bValue = b.geonameSort;
} else {
aValue = a[options.sort[0].key];
bValue = b[options.sort[0].key];
}
var ret = 0;
if (
(options.sort[0].operator == '+' && aValue < bValue)
|| (options.sort[0].operator == '-' && aValue > bValue)
) {
ret = -1;
} else if (
(options.sort[0].operator == '+' && aValue > bValue)
|| (options.sort[0].operator == '-' && aValue < bValue)
) {
ret = 1;
}
return ret;
});
}
data.items.sort(function(a, b) {
if (options.sort[0].key == 'geoname') {
aValue = a.geonameSort;
bValue = b.geonameSort;
} else {
aValue = a[options.sort[0].key];
bValue = b[options.sort[0].key];
}
var ret = 0;
if (
(options.sort[0].operator == '+' && aValue < bValue)
|| (options.sort[0].operator == '-' && aValue > bValue)
) {
ret = -1;
} else if (
(options.sort[0].operator == '+' && aValue > bValue)
|| (options.sort[0].operator == '-' && aValue < bValue)
) {
ret = 1;
}
return ret;
});
if (options.ids) {
data.positions = {};
data.items.forEach(function(place, i) {