[英]Calling an external JS library function with C#
我正在嘗試加載一個外部 javascript 文件( http://turfjs.org/我想在 C# 中使用的地理空間庫)並調用一個函數(在我的示例 turf.distance 中)我使用下面的代碼使用 Jint,但我有一個例外你能幫幫我嗎? 謝謝
String path = "turf.min.js";
String jsContent=File.ReadAllText(path);
try
{
var script = new Engine()
.Execute(jsContent)
.GetValue("turf.distance");
var result = script.Invoke(43.625, 3.61815, 43.6267, 3.60394);
}
catch (Exception exception)
{
// got an "Instance Error" (see image for details)
}
API 創建者已在 github ( https://github.com/Turfjs/turf/ ) 上給出了答案,他非常高效且可用於解決此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.