如何将 turf.js 与离子一起使用?

How to use turf.js with ionic?

我是 ionic 的新手,正在尝试在 ionic 应用程序中使用 turf。 首先我使用

通过 npm 安装它
npm install turf

这在节点模块中添加了 turf 文件夹。我将其复制到 lib 文件夹中。 然后我在索引页中将 link 添加到 turf.min.js。

它给出了这个错误

turf.featurecollection is not a function

使用代码 -

  var features = [
            turf.point([-97.502754, 35.463455], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.508269, 35.463245], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.516809, 35.465779], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.515372, 35.467072], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.509363, 35.463053], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.511123, 35.466601], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.518547, 35.469327], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.519706, 35.469659], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.517839, 35.466998], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.508678, 35.464942], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            }),
            turf.point([-97.514914, 35.463453], {
                "marker-color": "#6BC65F",
                "title": "Too Far",
                "marker-size": "small"
            })
        ];

        var fc = turf.featurecollection(features);

        var nearest = turf.nearest(point, fc);

        nearest.properties["marker-color"] = "#25561F";
        nearest.properties["title"] = "Nearest Point";
        nearest.properties["marker-size"] = "large";
        nearest.properties["marker-symbol"] = "star-stroked";

        var nearest_fc = turf.featurecollection([point, nearest]);

        var map = L.mapbox.map('map', 'charuoshan.0n1b363n')
            .setView([35.463453, -97.508014], 14);

        L.mapbox.featureLayer().setGeoJSON(fc).addTo(map);
        L.mapbox.featureLayer().setGeoJSON(nearest_fc).addTo(map);

看起来像是一个简单的错字。应该是 featureCollection.