1
當用戶在jsp頁面中給出日期作爲輸入時,所有緯度&經度被填充到java arraylist中。如何使用java arraylist在jsp中填充Google熱圖LatLng
我與ArrayList中的servlet -
String startDate=request.getParameter("from");
String endDate=request.getParameter("to");
List<LocInfo> rList=new ArrayList<LocInfo>();
try {
rList=LocBO.retrieveAll(startDate,endDate);
request.setAttribute("Map", rList);
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
RequestDispatcher rx=request.getRequestDispatcher("xyz.jsp");
rx.forward(request, response);
}
如何通過數組列表RLIST填充谷歌地圖經緯度在xyz.jsp?
<script>
var map, heatmap;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: {lat: 37.775, lng: -122.434},
mapTypeId: google.maps.MapTypeId.SATELLITE
});
heatmap = new google.maps.visualization.HeatmapLayer({
data: getPoints(),
map: map
});
}
function getPoints() {
return [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.751266, -122.403355)
];
}
</script>
JSON是唯一的解決辦法?如果是,請根據此servlet/jsp &地圖提供代碼。我是新來的。