 |
|
index.php
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shawn Mayzes - Google Maps jQuery Plugin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg"type="text/javascript"></script>
<script src="http://www.mayzes.org/js/jquery.googlemaps1.01.js"></script>
<script>
//<![CDATA[
var a= [ 'marker.php'];
var i=0;
var t;
function webs(){ //loop link
if (i >= a.length) i = 0;
return a[i++];
}
function loopShow(){ //show link at <div id="test"></div>
$('#test').load(webs(),function(){
if (t) window.clearTimeout(t);
t = window.setTimeout('loopShow()',1000);
});
}
$(function(){
loopShow();
});
//]]>
</script>
</head>
<body>
แผนที่ครับ
<div id="test" ></div>
</body>
</html>
marker.php
Code (PHP)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<?
$time = time();
$rest = substr($time, -2);
$lat = 15+".$rest".'44054';
$long = 120+".$rest".'45685';
?>
<script type="text/javascript">
/*window.setInterval(function(){
test();
}, 500);*/
$(document).ready(function test() {
$('#map_canvas').googleMaps({
markers: {
latitude:<?=$lat?>,
longitude: <?=$long?>
},
latitude:<?=$lat?>,
longitude: <?=$long?>,
depth: 10
});
});
</script>
<h3>Single Marker Example</h3>
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
หากเราต้องการให้ มีการ refresh เฉพาะ maker เราต้องเขียน function เพิ่มหรือเปล่าครับ ช่วยแนะนำ หน่อยนะครับผม
Tag : PHP, JavaScript, Ajax, jQuery
|
ประวัติการแก้ไข 2011-11-06 16:28:26
|
 |
 |
 |
 |
Date :
2011-11-06 16:27:27 |
By :
saberakito |
View :
1688 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |