How can I add markers to Google Maps using Node.js/Express/MongoDB?

后端 未结 1 1439
抹茶落季
抹茶落季 2020-12-17 04:55

I decided this week that I\'d like to learn Node.js (I\'m not a programmer). I\'ve been having a lot of fun with it so far but I\'m stuck at the moment.

I\'ve create

相关标签:
1条回答
  • 2020-12-17 05:36

    I JSON.stringify() any objects that my client scripts need and insert it as HTML5 data-whatever attributes.

    For example:

    //app.js
    app.get('/map', function(req, res){
      var data = {
        id: '1234',
        LL: {
          lat: 42.1,
          lng: 80.8,
      };
      res.locals.docsJSON = JSON.stringify([data]);
      res.render('locations/index');
    });
    
    //jade
    !!!
    html
      body(data-locations=locals.docsJSON)
      script
        var docs = JSON.parse($('body').attr('data-locations'));
        console.log(docs[0].LL);
    
    0 讨论(0)
提交回复
热议问题