Jump to content

Recommended Posts

Posted

Hi everyone,

I am currently in the proccess of creating a new flight map that looks cleaner and nicer than the google one. It even automatically resizes just to show the routes that have been flown. To use it, I need to find a way to make a list of DEPICAO-ARRICAO,DEPICAO-ARRICAO,DEPICAO-ARRICAO,DEPICAO-ARRICAO.

Example: KTPA-KMCO,KMCO-KMHT,KMHT-KMDW,KMDW-KLAS

Then, I need to insert that info into an image tag.

Example: <img src="http://www.gcmap.com/map?P=KTPA-KMCO,KMCO-KMHT,KMHT-KMDW,KMDW-KLAS&PM=pemr%3Adiamond7%2B%25U&MS=bm&DU=mi" border="0" title="Flight Map" alt="Flight Map" />

How can I go about calling up the info, putting in the KMCO-KTPA,KTPA-KMHT... format, and then inserting it into the image tag?

I've tried this so far, but it's failed miserably. I'm terrible with PHP.

<?php
$pilots = PIREPData::getAllReportsForPilot($pilotid);
foreach($pilots as $pilot)
{
 print_r($pilot);
}

?>

Thanks for all of your help,

Carl K.

CEO of SWAVA.net

  • Administrators
Posted

How about ->

<?php

$pilots = PIREPData::getAllReportsForPilot(Auth::$userinfo->pilotid);

foreach($pilots as $pilot)
   {  
       echo $pilot->depicao.' - '.$pilot->arricao.'<br />';
   }
?>

That will give you something like ->

KPQI - KBOS

KBOS - KATL

KORD - KDEN

KDEN - KMSP

KBUF - KBOS

KBOS - KPHL

KDEN - KMSP

KORD - KDEN

KOWD - KBDL

KBOS - KACK

KBOS - KLAX

Posted

Cool, I changed it a bit, and now it works perfectly. Thanks sooo much!

<?php

$pilots = PIREPData::getAllReportsForPilot(Auth::$userinfo->pilotid);

foreach($pilots as $pilot)
   {  
       echo $pilot->depicao.'-'.$pilot->arricao.',';
   }
?>

Sorry to sound so needy, but I have two more questions. (I've read the API guide but I still can't figure these things out on my own. Any ideas on places I can look to learn?)

Question 1: How can I implement a similar code on the homepage, but instead, display the info in the same map format for the last 20 accepted (or preferably, accepted PIREPs in the past XX days) PIREPS on my website?

Question 2: How can I implement a similar code on the PIREP Details Route_Map template, but instead, display the info in the same map format for the dep. and arr. ICAO associated to that PIREP?

Thanks again!!!

-Carl

  • Administrators
Posted
Question 1: How can I implement a similar code on the homepage, but instead, display the info in the same map format for the last 20 accepted (or preferably, accepted PIREPs in the past XX days) PIREPS on my website?

By count

<?php

$pireps = PIREPData::getRecentReportsByCount('20'); //20 = # of records

   foreach($pireps as $pirep)
       {
           echo $pirep->depicao.'-'.$pirep->arricao.',';
       }

?>

By days

<?php

$pireps = PIREPData::getRecentReports('2'); // 2 = # of days

   foreach($pireps as $pirep)
       {
           echo $pirep->depicao.'-'.$pirep->arricao.',';
       }

?>

Question 2: How can I implement a similar code on the PIREP Details Route_Map template, but instead, display the info in the same map format for the dep. and arr. ICAO associated to that PIREP?

not sure what you mean here... the pirep route map shows the dep and arr already.........

  • Like 1
Posted

Simpilot,

Thanks a TON! I don't even know how I can thank you enough.

As for #2, on the homepage, there are the 3 most recent PIREPs. If you click on one of the flight numbers, you see more details about the flight. At the bottom, it shows a route map. How can I get the code to display the dep ICAO-arr ICAO of the PIREP. Thanks!

Carl Klinker

  • Administrators
Posted

Simpilot,

Thanks a TON! I don't even know how I can thank you enough.

As for #2, on the homepage, there are the 3 most recent PIREPs. If you click on one of the flight numbers, you see more details about the flight. At the bottom, it shows a route map. How can I get the code to display the dep ICAO-arr ICAO of the PIREP. Thanks!

Carl Klinker

If you look around in the rest of the template, it's probably there somewhere. IIRC, it's

$pirep->depicao

And arricao

Guest Brian
Posted

Couldnt it be throw in as a Multidimensional Array? Atleast in VB is how you could do it.

  • Administrators
Posted

Couldnt it be throw in as a Multidimensional Array? Atleast in VB is how you could do it.

Arrays have nothing to do with anything here. He just needs a string

  • Administrators
Posted

I think what you are looking for shows up in the route_map.tpl view. The data for the map is being passed to that view using one of two variables depending on where the map is displayed, ($pirep or $schedule) $pirep is being used when looking at the flight details accessed from the frontpage. You should be able to get the data off that page with $pirep->arricao and $pirep->depicao. If you are trying to get the data from the db and use it in your own page you should use

$mydata = PIREPData::getReportDetails($pirepid);

The $priepid id the db id # of the prirep you are trying to get data for. Once you have that you can do a

print_r($mydata);

to see all the fields that are available, which are a ton including the aircraft data, airfields, pilot, etc...

Hope this helps.

  • 3 months later...
Posted

Okay... I can get the map to show on the front page with this:

and under the map, I get this:

KTPA-KMCO,KMCO-KMHT,KMHT-KMDW,KMDW-KLAS

by using this code:

<?php

$pireps = PIREPData::getRecentReportsByCount('20'); //20 = # of records

   foreach($pireps as $pirep)
       {
           echo $pirep->depicao.'-'.$pirep->arricao.',';
       }

?>

but, how can I get it to actually draw the lines on the map instead of it just showing the ICAO's under the map? Can you give me a step-by-step process for this please? This is on my home page of my site. click my badge to go there.

Posted

Here is how I have it in the frontpage_main.tpl

<img src="http://www.gcmap.com/map" alt="" width="700" height="360" />
<?php

$pireps = PIREPData::getRecentReportsByCount('20'); //20 = # of records

   foreach($pireps as $pirep)
       {
           echo $pirep->depicao.'-'.$pirep->arricao.',';
       }

?>

Posted

But Jeff, how do you get the lines to show ON the map? It just shows a blank map with the flights listed in text underneath?! What is the point of the map?!

Actually, wait....you are asking for that same thing, aren't you? Sorry. :wacko:

Posted

But Jeff, how do you get the lines to show ON the map? It just shows a blank map with the flights listed in text underneath?! What is the point of the map?!

That's what I was asking 3 posts up. I'd like to know how to get them to show the lines, because all it is showing is the ICAO codes with a blank map.

Guest lorathon
Posted

Here you go

<?php
$flights = PIREPData::getRecentReportsByCount(10);									
$string = "";
foreach($flights as $flight)
{	
     $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
}									
?>
       <table>
         <tr>
           <th>LAST 10 FLIGHT LEGS</th>
         </tr>
         <tr>
           <td><p align="center"><img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=650x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br />
             Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>.</p></td>
         </tr>
     </table>

Guest lorathon
Posted

I should have commented on the above.

It builds a string to insert into the URL image call. from the last 10 pireps that have been filed. Change the number in the () to change the amount of flights to display. The settings at the end of the URL are taken from the gcmap.com website. You can change it to look like you wish using these variables.

  • 2 months later...
  • 3 years later...
Posted

Hello guys,

I have used the code from the previous page and implemented it in the pilot_public_profile.tpl so it displays the map of pilots flights. But I am struggling with a problem, namely when the pilot has not flown any flights just over the blank map image, the error message pop up:

Warning: Invalid argument supplied for foreach() in .../pilot_public_profile.tpl on line 102

I have tried playing with a if function, but it doesnt work for me, or maybe I did it in wrong way.

Can anyone help me to solve this problem?

My code is:

<table id="pilotmap" style="border-collapse:collapse; width:590px;">
 <thead>
 <tr>
 <th style="width:100%">Last 10 flights</th>
 </tr>
 </thead>
 <tbody>
 <tr>
 <td>
<?php
 $string = "";
 foreach($pireps as $flight)
 {	
			 $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
 }															
?>
				 <p align="center"><img src="http://www.gcmap.com/map?P=<?php echo $string ?>%0D%0A&PM=b%3Asquare3%3Ablack%2B%22%25N%2213r%3Ablack&MS=wls&DU=mi" id="thumb" style="width:590px; height:360px;"/>


				 <br />
					 Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>.</p></td>
					 </tr>
					 </tbody>
					 </table>

P.S.

And one more thing, how do I make it to get the values of last 10 flights? Because in the original code from the previous page, there was such a line of code

$flights = PIREPData::getRecentReportsByCount(10);	

but I did delete it.

Cheers! :)

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...