Perl script as template
Daniel Morissette
danmo at videotron.ca
Thu Jun 8 14:01:19 PDT 2000
Zolla Michalak wrote:
>
> Sounds interesting. I'm not familiar with PHP though. Do you know where a
> good example is?
>
If you already know Perl then there should not be a huge learning curve
for PHP since I believe that it shares some if its syntax.
There is no info on the UMN MapServer web site yet for the PHP module,
but we have started a FAQ with pointers to some info at:
http://www2.dmsolutions.on.ca/mapserver/php_mapscript_faq.html
I included at the end of this message the sample test page that comes
with the PHP MapScript module. All it does is open a .MAP file, and
display the map, legend and scalebar.
If you want to look at something more advanced, there is an example of a
map navigation application on our web site that uses the PHP MapScript
module:
http://www2.dmsolutions.on.ca/gmap/gmap75.phtml
and you can download the whole application (including source code and
data, 2.4Mb) at:
http://www2.dmsolutions.on.ca/mapserver/gmap-20000515.tar.gz
Good Luck!
--
------------------------------------------------------------
Daniel Morissette danmo at videotron.ca
http://pages.infinit.net/danmo/
------------------------------------------------------------
Don't put for tomorrow what you can do today, because if
you enjoy it today you can do it again tomorrow.
<HTML>
<BODY BGCOLOR="#CCCCCC">
<CENTER>
<H1>PHP/MapScript module test</H1>
<P>
<?php
//
// This example opens a regular MapServer .MAP file, renders the main
// Map image (with the default layers enabled), the legend and the
// scale bar, and displays them in the HTML output.
//
//
// Load MapScript module.
//
if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
{
dl("php3_mapscript.dll");
}
else
{
dl("php_mapscript.so");
}
//
// Load MapServer .map file
//
// You can download the MapServer demo data from http://mapserver.gis.umn.edu/
//
$map = ms_newMapObj("demo.map");
// print $map->numlayers;
// phpinfo();
//
// RENDER MAIN MAP
//
// Note: If you get errors with the saveWebImage() call below, then make sure
// that the directory specified by IMAGEPATH in the .MAP file exists and is
// writable by the httpd user.
//
$img = $map->draw();
$url = $img->saveWebImage(0, 0);
printf("<IMG SRC=%s WIDTH=%d HEIGHT=%d>\n", $url, $map->width,
$map->height);
//
// LEGEND
//
$img = $map->drawLegend();
$url = $img->saveWebImage(0, 0);
printf("<P><IMG SRC=%s>\n", $url);
//
// SCALE BAR
//
$img = $map->drawScaleBar();
$url = $img->saveWebImage(0, 0);
printf("<P><IMG SRC=%s>\n", $url);
?>
</BODY>
</HTML>
More information about the MapServer-users
mailing list