|
 |
|
สอบถามการดึงข้อมูลละติจูดลองจิจูดมาจากฐานข้อมูลครับเพื่อ highlight เส้นทางสายถนนใน Google map api |
|
 |
|
|
 |
 |
|
อยากทราบว่าถ้านำโค้ดนี้ไปใช้เราจะต้องทำังไงถึงจะดึงข้อมูลละติจูด ลองจิจูด จากฐานข้อมูลเราเองมาใช้แทนการกำหนดจุดตายตัวแบบนี้บ้างครับCode (JavaScript)
// init map
var myOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
// init directions service
var dirService = new google.maps.DirectionsService();
var dirRenderer = new google.maps.DirectionsRenderer({suppressMarkers: true});
dirRenderer.setMap(map);
// highlight a street
var request = {
origin: "48.1252,11.5407",
destination: "48.13376,11.5535",
//waypoints: [{location:"48.12449,11.5536"}, {location:"48.12515,11.5569"}],
travelMode: google.maps.TravelMode.DRIVING
};
dirService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
dirRenderer.setDirections(result);
}
});
ตรงที่ origin: destination: อ่ะครับเราจะเอาข้อมูลนั้นมาจากฐานข้อมูลเราโดยเรากดค้นหาชื่อถนนในฐานข้อมูลของเราแล้วเอาค่าละติจูด ลองจิจูดที่เก็บไว้มาใช้ เราต้องเขียนโค้ดยังไงบ้างครับ หรือพอจะมีโค้ดให้บ้างรึป่าวครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax

|
|
 |
 |
 |
 |
Date :
2016-04-22 23:28:36 |
By :
doraemonpond |
View :
969 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (JavaScript)
var request = {
origin: "<?php echo $origin?>",
destination: "<?php echo $destination?>",
//waypoints: [{location:"48.12449,11.5536"}, {location:"48.12515,11.5569"}],
travelMode: google.maps.TravelMode.DRIVING
};
|
 |
 |
 |
 |
Date :
2016-04-23 10:00:25 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|