3

Is it possible to retrieve data "directly" from MongoDB to display them in an OpenLayers Map?

2 Answers 2

5

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.

0

If you are not strictly tied to MongoDB as a database, you can try CouchDB. It is also a JSON storage with integrated REST API and has a spatial extension GeoCouch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.