2

I want to use booleanCrosses and booleanContains methods from Turf.js library in my application on the client side, but I fail. I first tried to download just turf.min.js, but when in my code I call turf.booleanContains(...) I get

TypeError: turf.booleanContains is not a function

I also tried to download the whole turf archive and install needed packages with npm, but got a hell of error messages. So, what is the right way to install turf.js and some particular packages?

4

1 回答 1

3

我遇到了这个问题并通过使用纱线解决了这个问题。我的 node_modules 中有一个陈旧的草皮 index.d.ts(不清楚原因)。我希望我能准确地记住我做了什么,但是编辑 package.json (我把它们弄乱了以刺激纱线——尽管这可能没有做任何事情)

"@turf/boolean-contains": "^4.6.1",
"@turf/turf": "^4.6.1",

然后运行yarn(yarn 是 npm install/update 的更精简、更简单的替代品 - 通过 npm i -g yarn 安装并享受)

现在 index.d.ts 显示了其他模块(包括 booleanContains 这是我的具体问题)。

像这样导入模块:

import * as turf from '@turf/turf';

并按记录使用。

于 2017-08-24T22:17:48.097 回答