Buon giorno, ho questo problema, dopo una ricerca tramite DB, estrapolo alcuni dati tra i quali Latitudine e Longitudine, per comporre la Cartina messa a disposizione da Google.
Il problema che ho è che, non riesco a far passare dei valori da Php a Javascript, ho provato, ma evidentemente sono una pippa...Mi date una mano per favore?
codice:
//nella pagina read.php
//connessione
//verifica connessione
//compongo l'header
//eseguo la query
$query = ("SELECT location_id, quartiere, lat, lng, img FROM locations") or die ("Non è possibile eseguire la Select " . mysql_error());
if($txtQuartiere!=""){
$query .= " where quartiere = '" . $txtQuartiere . "'";
//echo "sono dentro quartiere";
}
$query = mysql_query($query);
$num_righe = mysql_fetch_array($query);
echo "<locations>";
echo '<location ';
echo 'location_id="'.$num_righe[0].'" ';
echo 'quartiere="'.$num_righe[1].'" ';
echo 'lat="'.$num_righe[2].'" ';
echo 'lng="'.$num_righe[3].'" ';
echo 'img="'.$num_righe[4].'" ';
echo '/>';
$strLat = str_replace(",",".",$num_righe[2]);
?>
//nella pagina dove c'è la funzione javascript index.html
<script type="text/javascript">
//<![CDATA[
function onLoad() {
var urlstr="Geo/Testmap1/read.php";
map = new GMap(document.getElementById("div_map"));
var quartiere = '<?php echo $strLat;?>;
//se quartiere è valorizzato devo prendere le coordinate per posizionarmi esattamente sul punto della cartina...
if(quartiere!=""){
//coordinate Quartiere
map.setCenter(new GLatLng('quartiere', 12.49813), 14);
}
else{
//coordinate sede AZIENDA
map.setCenter(new GLatLng(41.90174, 12.47147), 14);
}
getMarkers();
GEvent.addListener(map, "click", function(overlay, point) {
if (overlay){ // marker clicked
overlay.openInfoWindowHtml(overlay.InfoWindow);// open InfoWindow
} else if (point) { // background clicked
}
});
}
Mi dite per favore come, passare un valore da Php a Javascript?
Grazie mille..