Using Monodb in ArcGIS JavaScript

394
1
08-22-2022 06:50 AM
YunbeiOu
New Contributor II

Hi, I have created a web map showing the local authorities (WFS) of UK. And I want to customize the popup with data from my MongoDB database. I have all the data stored in the database. But I failed to connect to MongoDB database in JavaScript with following command:

 

    var MongoClient = require('mongodb').MongoClient;
    var url = "mongodb://localhost:27017/";
   
    MongoClient.connect(url, function(err, db) {
      if (err) throw err;
      var dbo = db.db("UKCP18_test");
    });
 
So, I wonder how to connect to MongoDB database and query data to show in pop-up content.
Tags (3)
0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

That's outside the scope of the ArcGIS JSAPI. You're probably better asking on stackoverflow or a Mongodb specific forum about how to get it to work. Once you can connect and fetch the data, you can integrate it into the ArcGIS JSAPI Popup using a pattern like this sample.

0 Kudos