Airport Information Addon

After receiving several requests by PM, I am releasing the addon I use to show the airports in the phpVMS database, with a separate page for each airport with various bits of data. First though I would like to attribute the work which I did not complete and is part of this addon.

    • This was originally created by Adamm, and I just removed some of the columns and added the link to the seperate webpage for the detailed airport info.
    • I asked for help on this forum, and Jeff (Lorathon) gave me the code to enable this feature.
    • Simpilot posted some code to show the flight count. I expanded on this to show the arrival and departure flight counts.
  • The Google Map - I reused and slightly modified (stripped out the ACARS functionality) the acars map from the default acarsmap.tpl here.
  • The js for the map display - Problem resolved my Mark1Million

I take absolutely no credit for the above mentioned aspects of the addon, and I would like to thank those mentioned for helping me create the addon released here. If you are going to thank anyone for this addon, thank those guys. I just put stuff together and added some more stuff. If you use this addon, I have placed attribution in the HTML commenting, please do leave it there.

If it doesn’t work on your site, I’m sorry but I can only provide limited support, as I’m still a learner when it comes to php. Please don’t PM me asking for support. You would be much better posting here and there is every chance that someone more knowledgeable may be able to help.

The addon can be seen working here:

http://execair.org/index.php/airports

The attached file has the same functionality but requires CSS styling to be applied. There are many tutorials available online, which discuss CSS styling at length, here are a few:

http://w3schools.com/Css/default.asp

http://www.csstutorial.net/

http://www.echoecho.com/css.htm

To install the addon, unzip the folder, then copy the contents of the core folder over to the core folder on your website. Then to access the addon, you need to create a link to the new page in your navigation:

<a href="<?php echo url('/airports'); ?>">Text for link here</a>

EDIT: Attached File Amended to correct all Map Errors mentioned below.

RE-EDIT: The attachment has been amended again to correct the errors. It should work 100% now.

[airportinfo_v3.zip](< base_url >/applications/core/interface/file/attachment.php?id=624)

Thank-you Stuart, this is a great addition to any VA.

Yes Same problem here, im just trying to debug with ff.

Thank-you Stuart, this is a great addition to any VA.

No worries Mark

he doesnt show any map on the airport information page, does someone have the same problem?

Try replacing the following in the airport_info.tpl file:

<?php 
/* These are the settings for the Google map. You can see the
Google API reference if you want to add more options.

There's two options I've added:

autozoom: This will automatically center in on/zoom 
  so all your current flights are visible. If false,
  then the zoom and center you specify will be used instead

refreshTime: Time, in seconds * 1000 to refresh the map.
  The default is 10000 (10 seconds)
*/
?>
var acars_map_defaults = {
autozoom: true,
   center: new google.maps.LatLng("<?php echo $name->lat; ?>", "<?php echo $name->lng; ?>"),
   mapTypeId: google.maps.MapTypeId.HYBRID };
</script>

with:

<?php 
?>
var acars_map_defaults = {
zoom: 14,
   center: new google.maps.LatLng("<?php echo $name->lat; ?>", "<?php echo $name->lng; ?>"),
   mapTypeId: google.maps.MapTypeId.HYBRID
};
</script>

If that works, I’ll amend the file in the attachment. I think it’s because I removed the zoom level in the attached file accidentally. I meant to delete the autozoom part.

EDIT: I’ve just found another mistake I made, sorry about this. In the airport_info.tpl file, there are two script tags here:

<script type="text/javascript">
<script type="text/javascript">
<?php 
?>
var acars_map_defaults = {
zoom: 14,
   center: new google.maps.LatLng("<?php echo $name->lat; ?>", "<?php echo $name->lng; ?>"),
   mapTypeId: google.maps.MapTypeId.HYBRID
};
</script>

Remove the top <script type=“text/javascript”> from the code. I was cut and pasting the code from my working site, to a new file, and made a few errors in doing so. let me know if the above changes work, and I’ll amend the attached file.

Thanks Stuart

Thanks Stuart

No worries mate.

I’ve amended the attached addon file with the corrections mentioned. The map should work now.

FFS: I’ve just spotted another error. I stripped out the styling from my working copy, but forgot that the map div needs to have width and height attributes set for the map to display properly.

Another change:

in the airport_info.tpl page again, find:

<div id="acarsmap"></div>

And set the width and height attributes like so:

<div id="acarsmap" style="width:672px;height:450px;></div>

You can change the values to whatever suits your layout best.

Amended the attached file again

Anyone get the map displaying yet? It’s working on my end, but it would be cool to know if I’ve corrected the errors properly. I don’t have much faith in my coding skills (or lack of) as it is

Still got no map mate but managed to add a NOTAM info to that page, Here

Mine is still not showing the map (http://www.flyaerova…rport?icao=CYYZ excuse the layout)

EDIT: Mark beat me to it.

Mine is still not showing the map (http://www.flyaerova…rport?icao=CYYZ excuse the layout)

EDIT: Mark beat me to it.

Could it be that the outer div container for the map needs to have the class defined in order for the js to output?

<div class=“mapcenter” align=“center” >

<div id=“acarsmap” style="width:672px;height:450px;></div>

</div

I’ll try removing the class tag from my page and see it it breaks the map, brb.

EDIT: Nope that isn’t it. I’m trying to figure out what the problem is, bear with me please.

To get the airport map work.

At the top of the page:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

Then where you like the map to be dispayed use this:

<script type="text/javascript">

     function initialize() {
       var mapDiv = document.getElementById('map-canvas');
       var map = new google.maps.Map(mapDiv, {
         center: new google.maps.LatLng(<?php echo $name->lat; ?> , <?php echo $name->lng; ?> ),
         zoom: 14,
         mapTypeId: google.maps.MapTypeId.SATELLITE
       });
     }


     google.maps.event.addDomListener(window, 'load', initialize);
   </script>
   <div id="map-canvas" style="width: 100%; height: 500px"></div>

You can change the:

mapTypeId: google.maps.MapTypeId.SATELLITE

to

mapTypeId: google.maps.MapTypeId.HYBRID

for the hybrid mode

To get the airport map work.

At the top of the page:

Then where you like the map to be dispayed use this:

You can change the:

mapTypeId: google.maps.MapTypeId.SATELLITE

to

mapTypeId: google.maps.MapTypeId.HYBRID

for the hybrid mode

Ahh Thanks Dimitris, I just realised why due to your post. I have minimised all my Javascript into one single file, so I don’t need to call the script from the page. It’s already called in the layout.tpl file. I wouldn’t have thought about that unless you posted.

EDIT: You don’t need to call the google maps script from the page it’s already called from the layout or header file as default. i can’t figure out how I could get it working without having to to use the initialise function? I can’t see any obvious differences from James’es to mine in the coding but mine works?

You are welcome

Ok i now have that working but with one change, instead of calling out to Google im using the existing file in the system

So,

<script type="text/javascript" src="<?php echo fileurl('/lib/js/acarsmap.js');?>"></script>
<br />
<h3><?php echo $name->name;?></h3>
<script type="text/javascript">

     function initialize() {
       var mapDiv = document.getElementById('map-canvas');
       var map = new google.maps.Map(mapDiv, {
         center: new google.maps.LatLng(<?php echo $name->lat; ?> , <?php echo $name->lng; ?> ),
         zoom: 14,
         mapTypeId: google.maps.MapTypeId.SATELLITE
       });
     }


     google.maps.event.addDomListener(window, 'load', initialize);
   </script>
   <div id="map-canvas" style="width: 100%; height: 500px"></div>

Get there in the end…

Ok i now have that working but with one change, instead of calling out to Google im using the existing file in the system

So,


<?php echo $name->name;?>

Get there in the end…

I’ve got headache now

Woot, thanks guys

Now this has definitely been a team effort! This is what makes phpVMS great

I still can’t suss out how it works in mine the way I listed, so I will amend the file to include Mark’s JS. I’m going with Mark’s as there is no need to call the google maps js again from the page. It’s already been called so it’s redundant to call it again. I’ll amend the attribution too, to reflect this.

Ah that’s no problem, just glad its working, great addition there

For the Notams, the code is in the forum here for that all you need to do is modify the code and create a new filename and include the variables for this page.

Infact here you go its easier just to paste it here seeing as were all in a sharing mood today .

<?php 

$stream = "http://www.ourairports.com/airports/$name->icao/notams.rss"; 

$file = new CodonWebService();
$contents = @$file->get($stream);
$xml = @simplexml_load_string($contents); 

$out = array(); 

$i = 1; 

if (!isset($xml->channel->item)) { 
   die("Sorry Nothing Found"); 
} 

foreach($xml->channel->item as $item) {  
   $data = array(); 
   $data['title'] = $item->title; 
   $data['description'] = $item->description; 
   $data['link'] = $item->link; 

   array_push($out, $data); 

   if ($i == 1) { 
       break; 
   } 
   $i--; 
}

echo $data['title'];
echo $data['description'];

$i = 2; 

if (!isset($xml->channel->item)) { 
   die("Sorry Nothing Found"); 
} 

foreach($xml->channel->item as $item) {  
   $data = array(); 
   $data['title'] = $item->title; 
   $data['description'] = $item->description; 
   $data['link'] = $item->link; 

   array_push($out, $data); 

   if ($i == 1) { 
       break; 
   } 
   $i--; 
}

echo $data['title'];
echo $data['description'];

$i = 3; 

if (!isset($xml->channel->item)) { 
   die("Sorry Nothing Found"); 
} 

foreach($xml->channel->item as $item) {  
   $data = array(); 
   $data['title'] = $item->title; 
   $data['description'] = $item->description; 
   $data['link'] = $item->link; 

   array_push($out, $data); 

   if ($i == 1) { 
       break; 
   } 
   $i--; 
}

echo $data['title'];
echo $data['description'];

?>

Place this in your active skins folder, then just include it where you want it.

Cool addition Mark! You could even go one step further and add the latest METARs code from the schedules_briefing.tpl and add that. The potential for a really informative addon is there.