4

I wonder if it's possible to retrieve data "directly" from MongoDB to display them in an OpenLayers Map? Maybe using some sort of API?

If you know more about this, or if you think it's a stupid question, let me know. Any kind of help will be appreciated.

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.

-1

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, privacy policy and cookie policy

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