Open
Description
This code fails:
if (Array.isArray(objects)) {
geojson = { type: "FeatureCollection", features: [] };
objects.forEach(function(item) {
geojson.features.push(
this.getFeature({ item: item, params: settings, propFunc: propFunc })
);
});
this.addOptionals(geojson, settings);
} else {
geojson = this.getFeature({
this
inside functions is bound to the function.
It needs to rewritten with arrow function so that this
is bound to the original object:
if (Array.isArray(objects)) {
geojson = { type: "FeatureCollection", features: [] };
objects.forEach((item) => {
geojson.features.push(
this.getFeature({ item: item, params: settings, propFunc: propFunc })
);
});
this.addOptionals(geojson, settings);
} else {
It's also good to use let
or const
instead of var
since the latter has global scope.
Thanks for writing this as I too struck the problem of the geojson
.js project not having @types
. I think the better path would have been to insist https://github.com/caseycesari/GeoJSON.js rename their project and create a .dt
. You seem to know them and perhaps you could have this conversation? :)
Metadata
Metadata
Assignees
Labels
No labels