passare i dati da database con php ad un array java

ho preso un listato google dove con un array visualizza i dati su una mappa. Ho provato a modificarlo cercando di riempire l'array con i dati presi da un database ma tutte le operazioni sull'array vengono praticamente ignorate.

da notare che in questo listato ho lasciato perdere l'array cosi' come era su google per cercare di caricarne uno mio.

gli alert inseriti mi servivano per vedere da dove passasse.

<?php
include("config.inc.php"); //parametri di connessione al database
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Complex icons</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>


<script language="javascript" type="text/javascript">
<!--
var miabeaches = new array();
alert("ok1");
// The following example creates complex markers to indicate beaches near
// Sydney, NSW, Australia. Note that the anchor is set to (0,32) to correspond
// to the base of the flagpole.

function initMap() {
// codime mio inizio
alert("ok2");
// var miabeaches = new array();
// alert("ok2");


<?php
$query1 = mysql_query("SELECT * FROM utenti where (id>=1 and id<=3)");

/*$num_righe = mysql_num_rows($query1);
$num_k = 0;*/


while($row=mysql_fetch_array($query1)){

?>
alert("ok3");
miabeaches[<?php echo $row["id"]; ?>]="<?php echo $row["lat"]; ?>";
alert("ok4");
<?php
}
?>
for (var i = 0; i < miabeaches.length; i++) {
var miabeach = miabeaches[i];
alert("mia"+miabeach);
}
// codice mio fine

var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: {lat: 40.4600608, lng: 17.2607627}
});

setMarkers(map);
}


// Data for the markers consisting of a name, a LatLng and a zIndex for the
// order in which these markers should display on top of each other.
var beaches = [
['Via xx,14', 40.4598764, 17.260803399999986, 4],
['Via yy,4', 40.4608176, 17.257222800000022, 5],
['Via zz,8', 40.4596252, 17.26048430000003, 3],
['Vicino', 40.4596252, 17.257222800000022, 2],
['Vicino', 40.4596252, 17.260803399999986, 1]
];

function setMarkers(map) {
// Adds markers to the map.

// Marker sizes are expressed as a Size of X,Y where the origin of the image
// (0,0) is located in the top left of the image.

// Origins, anchor positions and coordinates of the marker increase in the X
// direction to the right and in the Y direction down.
var image = {
url: 'd01.png',
// This marker is 20 pixels wide by 32 pixels high.
size: new google.maps.Size(20, 32),
// The origin for this image is (0, 0).
origin: new google.maps.Point(0, 0),
// The anchor for this image is the base of the flagpole at (0, 32).
anchor: new google.maps.Point(0, 32)
};
// Shapes define the clickable region of the icon. The type defines an HTML
// <area> element 'poly' which traces out a polygon as a series of X,Y points.
// The final coordinate closes the poly by connecting to the first coordinate.
var shape = {
coords: [1, 1, 1, 20, 18, 20, 18, 1],
type: 'poly'
};
for (var i = 0; i < beaches.length; i++) {
var beach = beaches[i];
var marker = new google.maps.Marker({
position: {lat: beach[1], lng: beach[2]},
map: map,
icon: image,
shape: shape,
title: beach[0],
zIndex: beach[3]
});
}
}

</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAtKhnrNidgFv7jU6AiPDJjGAjLMr4sJXQ&signed_in=true&callback=initMap"></script>

</body>
</html>

inviato un anno fa
echoes
X 0 X
Effettua l'accesso o registrati per rispondere a questa domanda