Hi,
How about adding an option to allow pre-fetching extra tiles?
I believe it will improve user experience with fast network, since the user will not see white space ultil loading done. With slow network, it will spoil performance though.
I'd apologize if this had been considered already.
--- leaflet-src.js 2017-05-28 10:30:08.435964020 +0900
+++ leaflet-src.js_tilemargin 2017-05-29 19:32:16.399501929 +0900
@@ -5486,9 +5486,10 @@
_pxBoundsToTileRange: function (bounds) {
var tileSize = this.getTileSize();
+ var margin = this.options.tileMargin; // default: 0
return new L.Bounds(
- bounds.min.unscaleBy(tileSize).floor(),
- bounds.max.unscaleBy(tileSize).ceil().subtract([1, 1]));
+ bounds.min.unscaleBy(tileSize).floor().subtract([margin, margin]),
+ bounds.max.unscaleBy(tileSize).ceil().add([margin - 1 , margin - 1]));
},
_noTilesToLoad: function () {
I was missing it, thanks!
I tried the plugin with a GeoJSON Layer, but it seems that GeoJSON Layer are not Grid-based Layers. It would be great to have such a feature for geoJSON Layer too. Any chance to prefetch tiles with GeoJSON Layers?
The Performance would not be affected that much, because the GeoJSON Data is loaded upfront and there is no reloading of data while panning or zooming.
@SvenLauterbach You could create a PR for @TolonUK - it shouldn't be that hard to achieve your feature request.
@SvenLauterbach Have you tried the padding option of the renderer you use? http://leafletjs.com/reference-1.0.3.html#renderer.
@SvenLauterbach in addition to @geoloep's suggestion, you can also set noClip: true if you really don't want geometries to be clipped outside the viewport.
Note however, that clipping is done for performance reasons: even if you don't have to load anything in for example a GeoJSON layer, rendering a lot of data _is_ expensive even if it's not visible. Of course, this depends on the complexity of your data, but in general it's wise to have clipping enabled and keep the padding to a reasonably small value.
Closing this, since nothing more to do as far as I can tell.
@geoloep does work like a charm, thank you.
Most helpful comment
@SvenLauterbach Have you tried the padding option of the renderer you use? http://leafletjs.com/reference-1.0.3.html#renderer.