|
|
|
ดูให้ทีครับ google api ติดต่อ mysql ไม่ขึ้น marker |
|
|
|
|
|
|
|
นั่งงมมาทั้งวันแล้วครับ T T
ไม่ขึ้นซักทีเลย
Code (PHP)
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=true"
type="text/javascript"></script>
<style>
header,
footer {
text-align: center;
}
#map {
display: block;
margin: 20px auto;
height: 400px;
width: 640px;
background-color: #ccc;
}
</style>
</head>
<body>
<?php
$host="localhost";
$username ="root";
$password ="";
$objConnect = mysql_connect($host,$username,$password);
$objDB = mysql_select_db("test");
$strSQL= "SELECT * FROM gg ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
?>
<header>
<h1>AIS API</h1>
<header>
<div id = "map" ></div>
<script type="text/javascript">
var locations = [ <?php while($objResult = mysql_fetch_array($objQuery))
{?>
{
['<?=$objResult["No"];?>',<?=$objResult["LAT"];?>,<?=$objResult["LONG"]; ?>, 1],
<?php } ?>
];
var map = new google.maps.Map(document.getElementById('map'),
{
zoom: 10,
center: new google.maps.LatLng(13.719374,100.581207),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++)
{
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2013-06-19 16:51:44 |
By :
zxperiaz |
View :
924 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แผนที่ขึ้นแล้วแต่ marker ไม่ขึ้น?
|
|
|
|
|
Date :
2013-06-20 05:56:12 |
By :
watcharop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|