Leaflet / Leaflet/Leaflet.VectorGrid
Can not slice a GeoJSON file containing just points
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 676
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
Prompted by https://stackoverflow.com/questions/44707862/how-to-add-geojson-points-as-a-vector-tile-in-leaflet
I tried to load a GeoJSON file containing only points (the one referenced in the SO question) like so:
fetch('https://raw.githubusercontent.com/evantdailey/map_testing/master/site1.geo.json').then(function(response){
return response.json();
}).then(function(json){
var points = L.geoJson(json);
map.fitBounds(points.getBounds());
var vectorGrid = L.vectorGrid.slicer( json, {
maxZoom: 20,
rendererFactory: L.svg.tile,
vectorTileLayerStyles: {
sliced: {
weight: 2,
color: 'red',
opacity: 1,
fillColor: 'yellow',
fill: true,
radius: 6,
fillOpacity: 0.7
}
}
});
vectorGrid.addTo(map);
})
Playground here. The GeoJSON is valid as per geojsonlint, and it loads if the code is changed to read var points = L.geoJson(json).addTo(map);
After a few minutes looking at the problem, I've discovered at least two problems when slicing geojson points:
-
The
L.VectorGrid.Slicerdoes not have aminZoomnormaxZoom. This affects the behaviour ofL.GridLayer.update(), asthis._tileZoombecomesundefined. The end result is that no tiles are displayed, so no tiles are requested togeojson-vt. Setting a defaultminZoomandmaxZoomshould alleviate this. I do not know if the defaultmaxZoomof 14 is being overwritten, or if there is some other race condition elsewhere. -
If
this._tileZoomis hacked during debug to allow some tiles to be requested, then_mkFeaturePartsthrows an exception. It is reminiscent of the cases where a point geometry is used but a linestring geometry is expected.
Unfortunately I don't have the time to debug this problem thoroughly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the linked point-only GeoJSON and the Leaflet.VectorGrid.Slicer example. Start by tracing L.GridLayer.update(), L.VectorGrid.Slicer, and the geojson-vt call, then inspect _mkFeatureParts for the point geometry failure. Done means point-only GeoJSON is sliced and rendered without missing tiles or exceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100