I've got Meteor.js to talk with Leaflet.js to be able to display limited markers around the $near query of a "2dsphere" indexed Collection.
So I index my GeoJSON coordinates:
Locations._ensureIndex({'geometry.coordinates':'2dsphere'});
It all works until I am using the $near operator to show markers beyond -90 to 90 longitude.
Latitude is bounding to -85 to 85, but longitude stops at -90 to 90 not -180 to 180 as expected.
So this works fine:
Leaflet map setView() to show the part of the map I want to place $near curson on:
window.map = L.map('map').setView([10,50],11);
Then the Server $near cursor - this works just as expected:
Meteor.publish('locations', function() {
return Locations.find({'geometry.coordinates':{ $near :
{ $geometry :
{ type : "Point" ,
coordinates: [10,50] } },
$maxDistance : 10000
}
});
});
But as soon as I adjust the coordinates to
[-33,151]
The leaflet map shows the location correctly, but the mongo $near throws an error:
$near requires a geojson point
Which is fair enough because that is an invalid point, but if I change it to:
[151,-33]
Then the Leaflet map doesn't show the correct location and the $near operator doesn't work.
Why are the geoJSON longitude coordinate limited between -90 to 90 ? and how do I show and use the $near operator on a location :
lat: -33 and long: 151