|
 |
|
ช่วยดูโค้ด google map หน่อยครับ รันออกมาหน้าจอเป็นสีขาวครับ รับค่ามาจากเพทอื่นครับ ใช้ค่าละติจูดลองจิจูด ในการปักหมุด |
|
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Map</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<style>
html {
height: auto;
}
body {
height: auto;
margin: 0;
padding: 0;
}
#map {
height: auto;
position: absolute;
bottom:0;
left:0;
right:0;
top:0;
}
@media print {
#map {
height: 950px;
}
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var locations = [
<?php
$id_prd=$_GET['id_prd'];
$sql="select * from tb_product where id_prd='$id_prd' ";
$result=mysql_db_query($db_Name,$sql);
while ($rs=mysql_fetch_array($result)) {
$id_prd=$rs[id_prd];
$code=sprintf("%05d",$id_prd);
$lat_prd=$rs[lat_prd];
$lng_prd=$rs[lng_prd];}
?>
[ <?=$id_prd?>, <?=$lat_prd?>, <?=$lng_prd?>]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: new google.maps.LatLng(14.85467, 103.48357),
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

|
ประวัติการแก้ไข 2011-06-16 22:50:19 2011-06-16 22:52:30
|
 |
 |
 |
 |
Date :
2011-06-16 21:52:42 |
By :
buraratn |
View :
2168 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่า ไปปักหมุดบน google Map แล้ว Copy link ของ มันมาใส่จะงาสยกว่ามะครับ
|
 |
 |
 |
 |
Date :
2011-06-17 15:48:11 |
By :
บลู |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอลแบบตรงๆเลยนะครับ ไม่รู้ทำไงครับ
|
 |
 |
 |
 |
Date :
2011-06-17 18:56:44 |
By :
buraratn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เศร้าไม่มีคนตอบ จ๊าก
|
 |
 |
 |
 |
Date :
2011-06-17 23:36:56 |
By :
buraratn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คันดึงมาอันเดียว .. บ่ต้อง ลง while loop ดอกครับผม แค่เปลี่ยนจาก
while ($rs=mysql_fetch_array($result)) {
เปลี่ยนเป็น
$rs=mysql_fetch_array($result);
|
 |
 |
 |
 |
Date :
2011-06-18 00:06:35 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้แก้ไขให้ใหม่ ให้ใช้ Google Earth ได้ด้วย
REF# https://www.thaicreate.com/community/google-map-earth-multiple-marker.html
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Map Test by Deawx</title>
<style type="text/css">
html {
height: auto;
}
body {
height: auto;
margin: 0;
padding: 0;
}
#map {
height: auto;
position: absolute;
bottom:0;
left:0;
right:0;
top:0;
}
@media print {
#map {
height: 950px;
}
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript"
src="https://www.google.com/jsapi?key=ABQIAAAA_KNcKfoyaTskjEp-kSSEjxSsDbTxMRg-JrUcPZT14QWonZA5mxRqx3ct_DbeHVelXNr1WbKEEJ5k-A"></script>
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/googleearth/src/googleearth-compiled.js" type="text/javascript"></script>
<script type="text/javascript">
google.load('earth', '1');
var map;
var googleEarth;
function init() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(15.105355046221582, 104.31570053100586),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
googleEarth = new GoogleEarth(map);
var locations = [
<?php
$id_prd=$_GET['id_prd'];
$sql="select * from tb_product where id_prd='$id_prd' ";
$result=mysql_db_query($db_Name,$sql);
$rs=mysql_fetch_array($result);
$id_prd=$rs[id_prd];
$code=sprintf("%05d",$id_prd);
$lat_prd=$rs[lat_prd];
$lng_prd=$rs[lng_prd];
?>
['<?=$id_prd?>', <?=$lat_prd?>, <?=$lng_prd?>, <?=$id?>]
];
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]),
draggable : false,
title : locations[i][0],
icon : 'http://maps.google.com/mapfiles/kml/pal3/icon48.png',
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})
(marker, i));
}
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
deawx
[email protected]
ปรึกษา PHP ฟรีจ้า
|
ประวัติการแก้ไข 2011-06-18 00:13:13
 |
 |
 |
 |
Date :
2011-06-18 00:10:33 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ ขอบคุณมากเลยครับพี่เดี่ยว
ใจดีมากๆ
|
 |
 |
 |
 |
Date :
2011-06-18 02:43:25 |
By :
buraratn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บ่เป็นหยังจ้า
|
 |
 |
 |
 |
Date :
2011-06-18 06:49:51 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|