Giter Site home page Giter Site logo

Comments (3)

IvanSanchez avatar IvanSanchez commented on June 3, 2024

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.

slutske22 avatar slutske22 commented on June 3, 2024

@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:

Screen Shot 2022-12-30 at 8 41 47 AM

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.

IvanSanchez avatar IvanSanchez commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.