This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

how to retrieve multiple points from MongoDB and plot them on OSM?

0

The data stored in my Database "video" of "shows" collection in mongodb is as this. It has 3 feilds as dose_rate, x, y.

My code for "app.js" is as follows :

var express=require('express');
var MongoClient=require('mongodb').MongoClient;
var engines=require('consolidate');
var assert=require('assert');
var app=express();

app.engine('html',engines.nunjucks);
app.set('view engine','html');
app.set('views',__dirname+ '/views');

MongoClient.connect('mongodb://localhost:27017/video',function(err,db){
assert.equal(null,err);
console.log("successfully connect to the MongoDB server");
app.get('/',function(req,res){
    db.collection('shows').find({}).toArray(function(err,docs){
        res.render('shows',{'shows':docs});
        });
      });
    });
 });

app.listen(4596,function(req,res){
console.log("connect to the port 4596");
});

the below code is for "shows.html" :

<!DOCTYPE html>
 <html>

<head>
<title>Plotting points</title>
</head>

<body>
<ul class="nav navbar-nav">
{%for show in shows%}
<li>{{show.dose_rate}}</li>
<li> {{show.x}}</li>
<li>{{show.y}}</li>
{%endfor%}
</ul>
</body>
</html>

on running the code of "app.js" and on opening "shows.html" from browser on localhost, the output is that all points (i.e dose_rate, x, y) of my "shows" collection in "video" database is displayed on HTML page as this.

now i did get code for plotting a point on OSM as marker from this link--> wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example independently without app.js running in background as simple HTML page.

I want to plot all my points stored in my collection "shows" as "x" and "y" from that db on OSM map, one by one, at once. I tried finding all reference to this problem but failed to find one. Please help me in doing so as i am new to OSM and nodejs or post any reference which i can read or tag someone who can help. THANK YOU IN ADVANCE

asked 15 Feb '17, 06:19

pnnp's gravatar image

pnnp
11112
accept rate: 0%

Source code available on GitHub .