我正在构建一个存储带坐标位置的简单API,我想根据它们与用户位置的距离来查询位置。
现在,我得到用户的位置:
Note: This is a warning about disabling a security feature. It is
supposed to be scary as we are disabling a security feature and we
can't just be silent about it! Downloads really shouldn't happen
any longer as root to decrease the attack surface – but if a warning
causes that much uproar, consider what an error would do…
The old WARNING message:
| W: Can't drop privileges for downloading as file 'foobar' couldn't be
| accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
is frequently (incorrectly) considered to be an error message indicating
that the download didn't happen which isn't the case, it was performed,
but without all the security features enabled we could have used if run
from some other place…
我尝试用以下方式查询位置:
var geolocation = angular.module('geolocation', []);
navigator.geolocation.watchPosition(render);
var lat, lon = 0;
function render(pos) {
lat = pos.coords.latitude;
lon = pos.coords.longitude;
console.log(lat +","+ lon);
}
我正在显示如下结果:
exports.find_all_locations_near = function(req, res) {
const $minDistance = req.query.minDistance;
const $maxDistance = req.query.maxDistance;
if ($minDistance > 0)
{
Location.find({
geolocation:
{
$near:
{
$geometry:
{
type: "Point",
coordinates: [lat, lon]
},
$minDistance,
$maxDistance
}
}
}), function(err, location) {
if (err) {
//console.log(err);
res.send(err);
}
else if (location =='')
//res.json({ message: 'No location was found.' });
res.json({ message: 'No location was found.' });
else
{
res.json(location);
res.json({ message: 'The end.' });
}
};
} else
{
Location.find({}, function(err, location) {
if (err)
res.send(err);
res.json(location);
res.json(req.params.minDistance);
});
}
}
如何查询计算距离的位置?我怎样才能使查询正常工作,因为我拒绝连接?
如果您需要更多信息,请使用github repo https://github.com/supermonteiro/geolocationAPI