gpt4 book ai didi

javascript - 传单和 MongoDB 半径

转载 作者:行者123 更新时间:2023-11-30 06:26:35 27 4
gpt4 key购买 nike

我想为我的搜索表单使用传单标记(用于 latLng)和 slider (用于半径)。
mongodb 部分将像

location: {
$geoWithin: {
$centerSphere: [[lon, lat], radius]
}
}

但半径似乎永远不是正确的。
我必须除/乘多少数字才能正确?

最佳答案

你应该对所有( map 和搜索)使用相同的单位。
在这种情况下,我更喜欢使用 meter。

传单已经使用了仪表单位。
所以你只需要使用 meter 进行查询。
根据this ,你应该使用 GeoJSON。
并确保索引为“2dsphere”。

关于javascript - 传单和 MongoDB 半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20718465/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com