Add tiler.getGeoJSON, useful for debugging tile settings

This commit is contained in:
Bryan Housel
2018-11-14 14:22:10 -05:00
parent 5f2ba5a100
commit 317a3be93b

View File

@@ -111,6 +111,31 @@ export function utilTiler() {
};
/**
* getGeoJSON() returns a FeatureCollection for debugging tiles
*/
tiler.getGeoJSON = function(projection) {
var features = tiler.getTiles(projection).map(function(tile) {
return {
type: 'Feature',
properties: {
id: tile.id,
name: tile.id
},
geometry: {
type: 'Polygon',
coordinates: [ tile.extent.polygon() ]
}
};
});
return {
type: 'FeatureCollection',
features: features
};
};
tiler.tileSize = function(val) {
if (!arguments.length) return _tileSize;
_tileSize = val;