[maplab-users] links from map to jpg

charley cheng chengcharlie2003 at yahoo.ca
Fri Aug 27 13:47:37 EDT 2004


Hi! Kevin,

Yesterday I was too busy in company¡¯s project and did not get chance to reply your mail, sorry for later reply.

I am also a beginner in programming PHP. The way I made the hyperlink work in query.phtml are in following code:



Job_no, Location, summary_2 and Siteplan are the attributes (columns) in shapefile I want to display. I put url as attribute value for Siteplan and summary_2. You can put the files (pdf,excel,--) in the URL under wwwroot in IIS or htdoc in Apache. When you click the "click to document", it hyberlink to the URL

Attached please find the code from Alberto Cavalli, who helps me solve the problem.



function formatQueryResults( $oResultSet, $aszLayers )

{

global $gaszWMSResults;



// initialize the variables

$szReturnValue = "";

$aszNoResults = array();



// loop through each result set and return

$nCount = $oResultSet->nNumResults;



for ( $i=0; $i<$nCount; $i++ )

{



// process each result set

$aRows = $oResultSet->getResultSet( $i );



// check if single or multiple results were returned

if ( is_array( $aRows ) )

{

// build title rows

$szReturnValue .= "<tr>\n";

$szReturnValue .= "<td>\n";

$szReturnValue .= "<table bgcolor=\"#999999\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">\n";

$szReturnValue .= "<tr>\n";

$szReturnValue .= "<td colspan=".count($aRows[0])." bgcolor=\"C1D8E3\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><u><b>".$aszLayers[$i]."</b></u></font></td>\n";

$szReturnValue .= "</tr>\n";

$szReturnValue .= "<tr>\n";



// loop and use key for titles

foreach ($aRows[0] as $key => $value)

{

if (strcasecmp($key, "Job_no") == "Job_no" ||

strcasecmp($key, "Location") == "Location" ||

strcasecmp($key, "Summary_2") == "Summary_2" ||

strcasecmp($key, "Siteplan") == "Siteplan" )



$szReturnValue .= "<td bgcolor=\"E2EFF5\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">".$key."</font></td>\n";

}

$szReturnValue .= "</tr>\n";



// loop through the results and format each row

foreach ( $aRows as $aRow )

{

// add a row for each

$szReturnValue .= "<tr>\n";



// loop and add a cell for each result

foreach ( $aRow as $key => $xCell )

{

//Look for the attribute value in column of Job_no, location, siteplan and //summary_2

if (strcasecmp($key, "Job_no") == "Job_no" ||

strcasecmp($key, "location") == "location" )

{$szReturnValue .= "<td bgcolor=\"#ffffff\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">". $xCell."</font></td>\n";}

else if (strcasecmp($key, "Siteplan") == "Siteplan" ||

strcasecmp($key, "Summary_2") == "Summary_2" )



//$xCell is the attribute value in URL format such as http://localhost/test/test.pdf



{$szReturnValue .= "<td bgcolor=\"#ffffff\"> <a href=\"".$xCell."\"> Click here to document</a></td>\n";}

}

$szReturnValue .= "</tr>\n";

}




Hope it can give you a litle help.
 
I have not used many time to learn php, the tutorial in www.php.net is enough.
 
Thank you !
 
Charlie
 
Code from Alberto
 
Hi Charlie, the code is very simple and it is only a starting point for building a custom query:
INFO, NUM_FOGLIO, NUM_PART, AREA, INFO_ID and ESPR1 are the fields of dbf of one layer. 
 

//loop and use key for titles## field from dbf that you want to display when you make a query

foreach ($aRows[0] as $key => $value)
{
if (strcasecmp($key, "INFO") == "INFO" ||
strcasecmp($key, "NUM_FOGLIO") == "NUM_FOGLIO" ||
strcasecmp($key, "NUM_PART") == "NUM_PART" ||
strcasecmp($key, "AREA") == "AREA" )

This part of code generate the titels of field that appear when you make a query


 

// loop and add a cell for each result## field that you don't want to display when you make a query
foreach ( $aRow as $key => $xCell )
{
if (strcasecmp($key, "INFO_ID") == 0 ||
strcasecmp($key, "ESPR1") == 0)
This part of code remove the value of field thath you don't want to display
 
 
 
 
 
use the same way to customize a query for multiple layer
for example:
first layer dbf: 3 field (id, area perimeter)
second layer dbf: 2 layer (name, dimension)
If you want to display only id, area and dimension use this is the code
 

// loop and use key for titles## CAMPI DA INCLUDERE
foreach ($aRows[0] as $key => $value)
{
if (strcasecmp($key, "ID") == "ID" ||
strcasecmp($key, "AREA") == "AREA" ||
strcasecmp($key, "DIMENSION") == "DIMENSION" )

$szReturnValue .= "<td bgcolor=\"E2EFF5\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">".$key."</font></td>\n";
}
$szReturnValue .= "</tr>\n";

// loop through the results and format each row
foreach ( $aRows as $aRow )
{
// add a row for each
$szReturnValue .= "</tr>\n";

// loop and add a cell for each result## CAMPI DA ESCLUDERE
foreach ( $aRow as $key => $xCell )
{
if (strcasecmp($key, "NAME") == 0 ||
strcasecmp($key, "PERIMETER") == 0)
continue;
$szReturnValue .= "<td bgcolor=\"E2EFF5\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">".$xCell."</font></td>\n";
}

$szReturnValue .= "</tr>\n";
}

Very important: be careful, use the righr sequency of field!!!!!!!!

 

 

Have a good work

Alberto

 
 


kgrootendorst at baird.com wrote:

Hi Charlie, 
I too am attempting to modify the query.phtml file in order to support 'hot linking' of jpeg photos. 
Have you had any success at this?   
Could you point me towards any references you may have used in order to accomplish this task? 
Does anyone know of any good beginner php programming websites? 

Thanks, 

Kevin




---------------------------------
Post your free ad now! Yahoo! Canada Personals
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/maplab-users/attachments/20040827/0944fb29/attachment.htm


More information about the Maplab-users mailing list