I am trying to pass latitude and longitude data from a MySQL database through my Spring Boot application into a javascript function. I was able to use Thymeleaf to display a table on the webpage with the data, so I know the service and controller classes are set up correctly.
Below shows how my table is populated:
<table style="word-wrap:break-word;white-space:normal;" class="table table-bordered">
<thead class="table-dark">
<tr>
<th>Latitude</th>
<th>Longitude</th>
<th></th>
</tr>
</thead>
<tbody>
<th:block th:each="point : ${listPoints}">
<tr>
<td>[[${point.LAT}]]</td>
<td>[[${point.LNG}]]</td>
</tr>
</th:block>
</tbody>
</table>
I also hard coded the params of my javascript function which works. Below is the js function:
addMarker({lat:50.772775,lng:3.889969});
function addMarker(coords) {
var marker = new google.maps.Marker({
position: coords,
map:map
})
}
I need a way to loop through my lat and lng’s to add a marker for each. Thank you!