Extraire des donnes dans une fonction Javascript
Bonjour je developpe une map pour un site, je dois afficher les positions de ma base de donner en utilisant php et les afficher sur la map
Ma question est: comment utiliser une fonction php qui insere les valeurs dans ma fonction javasctript
comme vous voyez dans mon code en bas dans ma fonction initialise() j'apelle la methode JavaScript
Code:
var myVar=pointA(44.5000,-73.5833);
Mais comment prendre les valeurs de la base de donne dynamiquement?
Merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| <!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
<script>
function pointA(x,y)
{
var busposition=new google.maps.LatLng(x,y);
return busposition;
};
var myCenter=new google.maps.LatLng(45.5000,-73.5833);
var busposition2=new google.maps.LatLng(41.5000,-73.5833);
function initialize()
{
var myVar=pointA(44.5000,-73.5833);
var mapProp = {
center:myCenter,
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:myVar,
icon:'school_bus.png'
});
var marker2=new google.maps.Marker({
position:busposition2,
icon:'school_bus.png'
});
marker.setMap(map);
marker2.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<?php
// Connect to database server
mysql_connect("localhost", "root","") or die (mysql_error ());
// Select database
mysql_select_db("location") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM coordinate";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// Write the value of the column FirstName (which is now in the array $row)
echo $row['longtitude'] . "<br />";
echo $row['Altitude'] . "<br />";
}
// Close the database connection
mysql_close();
?>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html> |