Merge pull request #84 from sikmir/fix-bounds

Gracefully handle missing tile service bounds in map preview
This commit is contained in:
Brendan Ward 2019-11-19 08:36:39 -08:00 committed by GitHub
commit fc91bd5a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,10 +84,13 @@
var layer = null;
d3.json('./', function(tileJSON) {
var b = tileJSON.bounds;
if (tileJSON.bounds) {
var b = tileJSON.bounds;
// TODO: optimize and prevent jitter
map.fitBounds([[b[1], b[0]], [b[3], b[2]]]);
}
// TODO: optimize and prevent jitter
map.fitBounds([[b[1], b[0]], [b[3], b[2]]]);
if (tileJSON.maxzoom && tileJSON.maxzoom < map.getZoom()){
map.setZoom(tileJSON.maxzoom);
}