From 7f5e1e2e622995df75637a0b96cd71c193cbac00 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Thu, 19 Jan 2017 19:30:34 +0100 Subject: [PATCH] Less hackish tile loading; also works with empty data --- examples/geojson-vt.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/geojson-vt.js b/examples/geojson-vt.js index 955e49cd9a..e00ce9f6a6 100644 --- a/examples/geojson-vt.js +++ b/examples/geojson-vt.js @@ -67,23 +67,22 @@ fetch(url).then(function(response) { format: new ol.format.GeoJSON(), tileGrid: ol.tilegrid.createXYZ(), tilePixelRatio: 16, - tileLoadFunction: function(tile, tileCoord) { + tileLoadFunction: function(tile) { var format = tile.getFormat(); - var data = tileIndex.getTile.apply(tileIndex, tileCoord); + var tileCoord = tile.getTileCoord(); + var data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1); var features = format.readFeatures( JSON.stringify({ type: 'FeatureCollection', - features: data.features + features: data ? data.features : [] }, replacer)); tile.setLoader(function() { tile.setFeatures(features); tile.setProjection(tilePixels); }); }, - tileUrlFunction: function(tileCoord) { - return [tileCoord[0], tileCoord[1], -tileCoord[2] - 1]; - } + url: 'data:' // arbitrary url, we don't use it in the tileLoadFunction }); var vectorLayer = new ol.layer.VectorTile({ source: vectorSource