s'il vous plaît je travaille dans le projet et je veux afficher de nombreux marqueurs sur la carte, je veux afficher arr [] [] de jsp à javascrpit comme ce code, s'il vous plaît je travaille dans le projet et je veux afficher de nombreux marqueurs sur la carte, je veux afficher arr [] [] de jsp à javascrpit comme ce code ex: je veux remplacer ce code:comment peut convertir tableau de jsp en javascript
for (var i = 0; i < 3; i++) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(17.088291,78.442383),
map: map,
});
à:
for (var i = 0; i < 3; i++) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(arr[i][0],arr[i][1]),
map: map,
});
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD4DvaNOnpTRUFASvy6lyY0DDVcfXytvnY&libraries=places&&callback=initMap">
</script>
<script>
<%!
double arr[][]= new double[3][2];
%>
<%
arr[0][0]=19.088291;
arr[0][1]= 78.442383;
arr[1][0]=18.088291;
arr[1][1]=78.442383;
arr[2][0]=17.088291;
arr[2][1]=78.442383;
%>
function loadMap() {
var mapOptions = {
center:new google.maps.LatLng(19.373341, 78.662109),
zoom:7
}
var map=new google.maps.Map(document.getElementById("sample"),mapOptions);
//animation:google.maps.Animation.BOUNCE
for (var i = 0; i < 3; i++) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(17.088291,78.442383),
map: map,
});
}
}
</script>
</head>
<body onload="loadMap()">
<div id="sample" style="width:580px;height:400px;"></div>
</body>
</html>
cet affichage de code un marqueur –
oui je sais, mais quand je remplacerai la boucle imbriquée à for (var i = 0; i <3; i ++) { marqueur var = new google.maps.Marker ({ position: nouveau google.maps.LatLng (arr [i] [0], arr [i] [1]), carte: carte, }); } ne fonctionne pas ... –
je pense que ... arr défini au code jsp mais le code javascript ne peut pas le lire –