MongoDB print distance between two points

后端 未结 3 1848
攒了一身酷
攒了一身酷 2020-11-28 12:46

When I am firing this query on MongoDB, I am getting all the places in the proximity of 500 miles to the specified co-ordinates. But I want to know the exact distance betwee

3条回答
  •  野性不改
    2020-11-28 13:15

    maxDistance -> Optional. The maximum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall within the specified distance from the center point.

    Specify the distance in meters if the specified point is GeoJSON and in radians if the specified point is legacy coordinate pairs.

    In the docs it says if you use legacy pairs , eg : near : [long , lat] , then specify the maxDistance in radians. If you user GeoJSON , eg : near : { type : "Point" , coordinates : [long ,lat] }, then specify the maxDistance in meters.

提交回复
热议问题