From 76a540e399c9c85f8e83eddc53d36a01ca0ad3ff Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 19 Jun 2012 17:57:21 +0200 Subject: [PATCH] Ox.API: better workaround for area --- source/Ox/js/Array.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/source/Ox/js/Array.js b/source/Ox/js/Array.js index 12f64d7d..e3876d2b 100644 --- a/source/Ox/js/Array.js +++ b/source/Ox/js/Array.js @@ -224,12 +224,24 @@ Ox.api = function(items, options) { east: data.area.ne.lng }; */ - data.area = { - south: Ox.MIN_LATITUDE, + data.area = items.length == 0 ? { + south: -Ox.MAX_LATITUDE, west: -180, north: Ox.MAX_LATITUDE, east: 180 - } + } : items.reduce(function(prev, curr) { + return { + south: Ox.min(prev.south, curr.south), + west: Ox.min(prev.west, curr.west), + north: Ox.max(prev.north, curr.north), + east: Ox.max(prev.east. curr.east) + }; + }, { + south: Ox.MAX_LATITUDE, + west: 180, + north: -Ox.MAX_LATITUDE, + east: -180 + }); } result.data = data; } else {