Is it possible to retrieve data "directly" from MongoDB to display them in an OpenLayers Map?
2 Answers
There is no way to do it "directly"... One way is to design a REST web service which would return GeoJSON data. A typical example is your client (OpenLayers map) sending a request to your server with the bounding box of your map viewport as parameter.
All the mapping javascript libraries allow you to get the extent of the viewport. It's pretty easy then to include these parameters to an URL and send a request to your server with JQuery.
Once your server gets the request, it will query your mongodb database. One way is to use mongoose.js to deal with mongodb in a node.js architecture. It will then send the data inside the box to the client which will display the data.