0

I'm trying to use the Leaflet.VectorGrid API to load a GeoJSON in a leaflet map, but no matter what I try I keep getting this error:

Uncaught (in promise) TypeError: this._makeFeatureParts is not a function
    at e.initialize (vectorgrid.js:1085)
    at e (leaflet.js:5)
    at e._createLayer (vectorgrid.js:1039)
    at e.<anonymous> (vectorgrid.js:977)
    at <anonymous>

It looks like the source of the error is this part of the JavaScript:

_makeFeatureParts: function(t, e) {
    var r = t.geometry[0][0];
    "x" in r && (this._point = L.point(r.x * e, r.y * e),
    this._empty = L.Util.falseFn)
}

which is lines 1092-1096 of source script.

The GeoJSON I'm using is a bunch of points, and works with other Leaflet functions.

This is the relevant part of the script I'm using for the vector grid:

var vectorGrid = L.vectorGrid.slicer(myGeoJSON).addTo(map);

Any idea what I'm missing that's generating that error? I was hoping to just be able to add a simple layer to see how it worked, but now I can't get past the first step. I've tried different GeoJSONs and adding more to the command, but with no luck.

Edit: I was able to get a working solution by reading up on the info provided by the answer below. Here's what I did to get it to work..

Evan
  • 1,960
  • 4
  • 26
  • 54
  • 1
    I'm getting a different error with all kinds of point GeoJSON files, maybe this issue here is related: https://github.com/Leaflet/Leaflet.VectorGrid/issues/94 I'm unable to confirm this, getting build errors when trying to compile the library... – chrki Jun 15 '17 at 00:06
  • I hadn't seen that issue, but I get the same error if I use their `points`. From reading on that issue and https://github.com/haoliangyu/ngx-leaflet-starter/issues/35 and https://github.com/Leaflet/Leaflet.VectorGrid/issues/32 it looks like `vectorGrid.slicer` doesn't currently support GeoJSON points, but might soon? – Evan Jun 15 '17 at 16:13

1 Answers1

2

There was a bug in the library to get the coordinates of GeoJSON points.

This problem has been fixed in its master branch, but the fix is not published yet. If you cannot wait for the v1.3.0 release, you can install the library from GitHub directly.

See the PR https://github.com/Leaflet/Leaflet.VectorGrid/pull/62

Haoliang Yu
  • 2,987
  • 7
  • 22
  • 28