Comments (3)
The code expects that promise to resolve to a vector tile, and not to the geojsonvt
instance (which holds multiple tiles, at least in the general case). Leverage .getTile()
on the geojsonvt
instance.
from leaflet.vectorgrid.
@IvanSanchez sorry to bother on what is more of a question than an issue, but I don't see how this is supposed to work exactly. I try something like
return vt.getTile(z, y, x) // where z, y, x comes from the coord argument
I get the error Cannot read properties of null (reading 'layers')
. I dug into some of the source code and examples, and I see that _getVectorTilePromise
is sometimes written to return an object with a .layers
and .coords
property. So I tried this:
return { layers: vt.getTile(z, x, y), coords }
But that gives the error Cannot read properties of undefined (reading 'length')
. That appears to be erroring on the .features
property from within the vectorgrid source code. When I check the GeoJSON being fed to geojsonvt, it seems to be a correct .features
array:
Apparently sometimes the getTile
function returns null. I fixed that with a check:
// With check to make sure function returns a non-null value
return (
vt.getTile(z, x, y)?.features ?? {
features: [],
numFeatures: 0,
numPoints: 0,
numSimplified: 0,
source: [],
transformed: true,
...coords
}
);
Which supresses the errors. But still, nothing renders here.
What am I doing wrong in this case? (Sandbox is updated to show the new code)
from leaflet.vectorgrid.
Read https://github.com/Leaflet/Leaflet.VectorGrid/blob/master/src/slicerWebWorker.js (or an old workerless version of the Slicer). Debug and compare how the slicer works versus how your code works.
from leaflet.vectorgrid.
Related Issues (20)
- Consuming compressed vector image responses
- Uncaught Error: Unimplemented type: 3 HOT 2
- protobuf vectorgrid is not handling Long Integers why? HOT 4
- Build failed HOT 1
- Toggle polygon HOT 1
- I cant display points. I can't change the style points/polygons. HOT 1
- Define bounds or extent of VectorGrid layer HOT 2
- Demo pages with points don't work HOT 1
- Layer order inside a tile
- Some tiles not rendering HOT 2
- Uncaught TypeError: Cannot read properties of undefined (reading 'lat') HOT 4
- support L.divIcon
- Protobuf - Get clicked feature (or its geometry)
- Problem with Leaflet >= 1.8 HOT 3
- remove added layer from map HOT 2
- Project status / Alternative Fork?
- fillOpacity and fillColor have no effect when rendering circlemarkers HOT 1
- Styling points/circles differently from Polygons
- How can I use maxNativeZoom to continue to show the vector tiles beyond their maximum zoom level?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.vectorgrid.