I figured it out guys. How to make routes appear and all!!! Here's the code:
In Destinations.tpl:
function addMarker(lat, lng, icontype, info){
if(icontype == "default"){
var image = "<?php echo fileurl('lib/images/mapassets/airport_icon.png'); ?>";
}else if(icontype == "hub"){
var image = "<?php echo fileurl('lib/images/mapassets/hub_icon.png'); ?>";
}
var marker = new google.maps.Marker({
position: CreateLatLngObject(lat, lng),
map: map,
icon: image
});
// Add this code
[b]google.maps.event.addListener(marker, 'click', function() {
for (i=0; i<lines.length; i++)
{
lines[i].setMap(null); //or line[i].setVisible(false);
}
$.getJSON("<?php echo actionurl("Destinations/getAirportsByArpt"); ?>/" + info.icao, function (data) {
$.each( data, function( key, val ) {
var line = new google.maps.Polyline({
path: [CreateLatLngObject(lat, lng), new google.maps.LatLng(val.lat, val.lng)],
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2,
geodesic: true
});
line.setMap(map);
lines.push(line);
});
});
});[/b]
[b]// END NEW CODE[/b]
google.maps.event.addListener(marker, 'mouseover', function() {
$("#info_icao").html(info.icao);
$("#info_name").html(info.name);
$("#info_country").html(info.country);
});
myMarkers.push(marker);
}
Now in Destinations.php, you have to add this method:
public function getAirportsByArpt($icao){
$sql = "SELECT b.* FROM phpvms_schedules as a LEFT JOIN phpvms_airports as b on b.icao=a.arricao WHERE a.depicao = '$icao' GROUP BY a.arricao";
echo json_encode(DB::get_results($sql));
}
Note: you may have to replace phpvms with ur prefix for tables...
Also: If you want to only show the airports that have routes connecting to them, modify the getAirports() method as follows:
public function getAirports(){
$airports = DB::get_results("SELECT b.* FROM phpvms_schedules as a LEFT JOIN phpvms_airports as b on b.icao=a.depicao GROUP BY a.depicao");
echo json_encode($airports);
}
Have fun!