Skip to content

Instantly share code, notes, and snippets.

@WillieYang
Last active June 21, 2017 14:54
Show Gist options
  • Select an option

  • Save WillieYang/f854af0459e5ab1e70ac81e205702a0a to your computer and use it in GitHub Desktop.

Select an option

Save WillieYang/f854af0459e5ab1e70ac81e205702a0a to your computer and use it in GitHub Desktop.
When using the GeoNear() funcition in Mongoose, cannot get the ideal result(the result is empty)
// But when input the exact the same coordinate of a place I have stored in the database, it would be revealed.
// As for GeoJSON format, the unit of distance is meters.
// GeoJSON Multipoint require 2dsphere:
{
type: "MultiPoint",
coordinates: [
[ -73.9580, 40.8003 ],
[ -73.9498, 40.7968 ],
[ -73.9737, 40.7648 ],
[ -73.9814, 40.7681 ]
]
}
// Legacy coordinate pair require 2d index.
{
$near: [ <x>, <y> ],
$maxDistance: <distance in radians>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment