diff --git a/lib/mbtiles.js b/lib/mbtiles.js index 9b437d2..6e4e9f4 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -42,7 +42,10 @@ function MBTiles(uri, callback) { if (err) return callback(err); else if (!exists) mbtiles.setup(this); else this(null); - }, callback); + }, function(err) { + if (err) callback(err); + callback(null, mbtiles); + }); }; // Finds all mbtiles file in the filepath and returns their tilesource URI. @@ -482,8 +485,8 @@ MBTiles.prototype.getInfo = function(callback) { info.minzoom = parseInt(info.minzoom, 10); info.maxzoom = parseInt(info.maxzoom, 10); info.bounds = _((info.bounds || '').split(',')).map(parseFloat); - info.center = _((info.center || '').split(',')).map(parseFloat); - if (!info.center) info.center = [ + if (info.center) info.center = _((info.center).split(',')).map(parseFloat); + if (!info.center || info.center.length !== 3) info.center = [ (info.bounds[2] - info.bounds[0]) / 2 + info.bounds[0], (info.bounds[3] - info.bounds[1]) / 2 + info.bounds[1], (range <= 1) ? info.maxzoom : Math.floor(range * 0.5) + info.minzoom