Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. const locationSchema = new Schema({
  2.  
  3. lat: String,
  4. lng: String,
  5. title: String
  6.  
  7. });
  8.  
  9. app.get('/', function(req,res){
  10.  
  11. Locations.find({}, (err, results) => {
  12. if (err) {
  13. return res.render.status(500).send('<h1>ERROR</h1>');
  14. } else{
  15. console.log(results)
  16. res.render('homePage',{results, Locations, req});
  17. }
  18. });
  19. });
  20.  
  21. // THIS WORKS
  22. <% for (const location of results) { %>
  23. <h1> <%= location.title %></h1>
  24. <h1> <%= location.lat %></h1>
  25. <h1> <%= location.lng %></h1>
  26. <% } %>
  27.  
  28. // This is invalid syntax
  29. <script>
  30. <% for (const location of results) { %>
  31. addMarker({coords:{lat: location.lat, lng: location.lng}, title: location.title});
  32. <% } %>
  33.  
  34.  
  35. //Add Marker Function
  36. function addMarker(props){
  37. var marker = new google.maps.Marker({
  38. position: props.coords,
  39. map:map,
  40. title: props.title
  41. })
  42. }
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement