簡體   English   中英

如何使用mongoose應用geoNear並獲得兩個坐標之間的距離

[英]How to apply geoNear with mongoose and get distance between two coordinates

我正在尋找一種解決方案,通過在Node中應用查詢來從我的集合中檢索文檔。 目的是檢索兩個坐標之間的距離。 它可以使用Native MongoDb實現,但我想用mongoose獲得結果。 我怎么做 ?

來自geoNear方法如下:

Model.geoNear([1,3], { maxDistance : 5, spherical : true }, function(err, results, stats) {
   console.log(results);
});

// geoJson
var point = { type : "Point", coordinates : [9,9] };
Model.geoNear(point, { maxDistance : 5, spherical : true }, function(err, results, stats) {
   console.log(results);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM