 |
ถามเรื่อง google map api คับ ทำยังไงเราจะเอา ผลการค้นหาที่ได้ มา มาร์ดจุดใน google map |
|
 |
|
|
 |
 |
|
Code (PHP)
<script type="text/javascript">
var map;
function LoadMap(a,b,c,d) {
var strLocationX = a;
var strLocationY = b;
var locationX = parseFloat(strLocationX);
var locationY = parseFloat(strLocationY);
if (!isNaN(locationX) && GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setUIToDefault();
//map.setCenter(new GLatLng(locationX, locationY), 14);
map.setCenter(new GLatLng(locationX, locationY), d);
var myPropertyMarker = new GMarker(new GLatLng(locationX, locationY));
/* กำหนด Info window แบบเฉพาะตัวให้ผุดขึ้นเมื่อคลิกที่ตัว marker */
GEvent.addListener(myPropertyMarker, "click", function () {
myPropertyMarker.openInfoWindowHtml(c);
});
map.addOverlay(myPropertyMarker);
myPropertyMarker.openInfoWindowHtml(c);
}
else {
document.getElementById("map_canvas").style.visibility = "hidden";
document.getElementById("map_canvas").style.display = "none";
}
}
</script>
<?
//ข้อมูลที่ดึงมาจาก ฐานข้อมูล
$title=$result[title];
$lat_value=$result[lat_value];
$lon_value=$result[lon_value];
$zoom_value=$result[zoom_value];
?>
<script type="text/javascript">
window.onload = function(){
var aa=<?=$lat_value?>;
var bb=<?=$lon_value?>;
var cc="<?=$title?>";
var dd=<?=$zoom_value?>;
LoadMap(aa,bb,cc,dd);
}
</script>
<div id="map_canvas" style="width: 550px; height: 500px"></div>
ตัวแปร a,b,c,d นั้นไล่ดูนะครับพอดีผมทดสอบ เขียนเลยไม่ได้ตั้งชื่อให้มันอ่านง่าย
ลองไล่ดูนะครับ
|
 |
 |
 |
 |
Date :
2011-02-25 11:44:34 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หมายถึงให้มันโชว์ไอค้อนบนแผนที่ เฉพาะคำที่เราค้นหาหนะหรอครับ
|
 |
 |
 |
 |
Date :
2011-02-25 20:13:45 |
By :
indysoft |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ละคับ ขอบคุณมากมายเลยคับ
|
 |
 |
 |
 |
Date :
2011-02-25 20:51:01 |
By :
boodemon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากได้โค้ด รับค่าจาก txt แล้วคำนวนระยะทางไม่เกินค่าที่ใส่มาครับ แล้วให้แสดงหมุดที่ค้นเจอ
|
 |
 |
 |
 |
Date :
2011-06-20 14:06:41 |
By :
buraratn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอาไปเล่นดู
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Search Along a Route Example</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/routeboxer/src/RouteBoxer.js" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var boxpolys = null;
var directions = null;
var routeBoxer = null;
var distance = null; // km
function initialize() {
// Default the map view to the continental U.S.
var mapOptions = {
center: new google.maps.LatLng(37.09024, -95.712891),
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoom: 4
};
map = new google.maps.Map(document.getElementById("map"), mapOptions);
routeBoxer = new RouteBoxer();
directionService = new google.maps.DirectionsService();
directionsRenderer = new google.maps.DirectionsRenderer({ map: map });
}
function route() {
// Clear any previous route boxes from the map
clearBoxes();
// Convert the distance to box around the route from miles to km
distance = parseFloat(document.getElementById("distance").value) * 1.609344;
var request = {
origin: document.getElementById("from").value,
destination: document.getElementById("to").value,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}
// Make the directions request
directionService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(result);
// Box around the overview path of the first route
var path = result.routes[0].overview_path;
var boxes = routeBoxer.box(path, distance);
drawBoxes(boxes);
} else {
alert("Directions query failed: " + status);
}
});
}
// Draw the array of boxes as polylines on the map
function drawBoxes(boxes) {
boxpolys = new Array(boxes.length);
for (var i = 0; i < boxes.length; i++) {
boxpolys[i] = new google.maps.Rectangle({
bounds: boxes[i],
fillOpacity: 0,
strokeOpacity: 1.0,
strokeColor: '#000000',
strokeWeight: 1,
map: map
});
}
}
// Clear boxes currently on the map
function clearBoxes() {
if (boxpolys != null) {
for (var i = 0; i < boxpolys.length; i++) {
boxpolys[i].setMap(null);
}
}
boxpolys = null;
}
</script>
<style>
#map {
border: 1px solid black;
}
#controls {
font-family: sans-serif;
font-size: 11pt;
margin-top: 10px;
margin-left: 20px;
</style>
</head>
<body onload="initialize();">
<div id="map" style="width: 512px; height: 400px;"></div>
<div id="controls">
Box within at least
<input type="text" id="distance" value="40" size="2">miles
of the route<br/>
from
<input type="text" id="from" value="Denver"/>
to
<input type="text" id="to" value="Houston"/>
<input type="submit" onclick="route()"/>
</div>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-06-20 14:21:00 |
By :
TEST |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอดู code ของคุณสายหมอกหน่อยได้มั้ยคับ
พอดีผมลองทำแล้วทำไม่ได้
ขอบคุณมากคับ
|
 |
 |
 |
 |
Date :
2011-09-06 11:54:16 |
By :
zeero |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สร้างแผนที่ใน Google Map แล้ว แต่พอลอง Search ไม่เห็นเจอแผนที่ๆ สร้างไว้เลยค่ะ ตอนสร้างแผนที่ก็ set เป็น public แล้วนะค้ะ ไม่รู้จะทำงัยดี ช่วยแนะนำด้วยนะค้ะ
ขอบคุณมากๆ เลยค่ะ
เอ
|
 |
 |
 |
 |
Date :
2011-09-27 12:18:50 |
By :
เอ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|