2016-08-31 5 views
0

私はイオニックに新しく、turfをイオンアプリで使用しようとしています。 は、最初のiノードモジュールにionicでturf.jsを使用するには?

npm install turf 

この追加された芝のフォルダを使用してNPMを介してそれをインストール。これをlibフォルダにコピーしました。 次に、インデックスページの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); 

答えて

2

は、単純なタイプミスのように見えます。 featureCollectionである必要があります。

+0

Ops .... :(You r right愚かな誤り。....ありがとう – Charu

関連する問題