Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const locationSchema = new Schema({
- lat: String,
- lng: String,
- title: String
- });
- app.get('/', function(req,res){
- Locations.find({}, (err, results) => {
- if (err) {
- return res.render.status(500).send('<h1>ERROR</h1>');
- } else{
- console.log(results)
- res.render('homePage',{results, Locations, req});
- }
- });
- });
- // THIS WORKS
- <% for (const location of results) { %>
- <h1> <%= location.title %></h1>
- <h1> <%= location.lat %></h1>
- <h1> <%= location.lng %></h1>
- <% } %>
- // This is invalid syntax
- <script>
- <% for (const location of results) { %>
- addMarker({coords:{lat: location.lat, lng: location.lng}, title: location.title});
- <% } %>
- //Add Marker Function
- function addMarker(props){
- var marker = new google.maps.Marker({
- position: props.coords,
- map:map,
- title: props.title
- })
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement