This answer is working fine with hardcoded locations but I want to use my <c:forEach var="location" items="${latlng.rows}">
and populate the locations
variable from database with <sql:setDataSource>
tag. I have 6 rows in my database table but I get only the last marker from database on the map.
This is hardcoded version which works fine:
<script type="text/javascript">
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
.....
</script>
Here is my code which doesn't work:
<script type="text/javascript">
var locations = [
<c:forEach var="location" items="${latlng.rows}">
[<c:out value='${location.name}'/>,
<c:out value='${location.latitude}'/>,
<c:out value='${location.longitude}'/>,
<c:out value='${location.id}'/> ],
</c:forEach>
];
.....
</script>
How can I get output from forEach items row to works like hardcoded version?