Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
598 stars 194 forks source link

Can I use the entire canvas to render instead of generating a canvas for each tile? #182

Closed gee1k closed 5 years ago

gee1k commented 5 years ago

Can I use the entire canvas to render instead of generating a canvas for each tile?

tomchadwin commented 5 years ago

I don't think so, as that's fundamental to how VectorGrid works. Each canvas is rendered with a buffer which is subsequently clipped. But others know better than I.

IvanSanchez commented 5 years ago

No. Using one canvas per tile is exactly the point of vectorgrid.

It might be possible to make a crossover between VectorGrid and L.TileLayer.NoGap, but that requires work.

IvanSanchez commented 5 years ago

Each canvas is rendered with a buffer which is subsequently clipped.

Not really - there is no buffer in the canvas itself. The coordinates of the vector data might form a buffer around each canvas, but the pixels that fall outside the canvas are not drawn AFAIK.

See the SVG viewbox for comparison, it works in a similar way (there might be stuff outside the viewbox, but that'll be just cropped): https://github.com/Leaflet/Leaflet.VectorGrid/blob/3a336694a82dc45c6c96746c2cd01193cf1ba0f2/src/Leaflet.Renderer.SVG.Tile.js#L13

gee1k commented 5 years ago

Each tile generates a canvas separately, and there will be problems like #110 . If you use the entire canvas, this problem will not occur. I think the mapbox seems to be like this.

IvanSanchez commented 5 years ago

...and that would mean clipping lines/polygons but not points (circles/images), extending/cropping the canvas on map pan, and a whole new set of problems. I understand what you mean, but I'm afraid your approach is naïve.

gee1k commented 5 years ago

Thank you! What you said is very reasonable. However, I am currently plagued by this problem for a long time. I tried to buffer the data of each tile in the Geoserver, and let some edges of each tile have some duplicate data to solve this problem. Also failed to succeed...