[mapserver-users] help

Jeff McKenna jmckenna at gatewaygeomatics.com
Tue Nov 18 15:28:40 PST 2008


Attila Borbás wrote:
> Hello,
> 
> I ve got a big problem with php/mapscript.I ve tried a simple "hello 
> world" example (from Beginning MapServer Open Source GIS Development) 
> and I didn't get any error message, but the browser couldn't generate 
> the rendered pic. I don't know what the problem could be, but all codes 
> what I ve made had the same problem. I attached the bad codes. Thx for 
> ur help and I'm looking forward to your answer.
> 
> _The php/mapscript file:_
> 
> <?php
> dl('php_mapscript.dll');
> 
> $image_name = sprintf("phpms-hello%0.6d",rand(0,999999)).".png";
> 
> $map = ms_newMapObj("c:/ms4w/Apache/htdocs/hello_world/hello.map");
> 
> $image=$map->draw();
> 
> $image->saveImage("c:/ms4w/tmp/ms_tmp/".$image_name);
> 
> ?>
> 
> <html>
> <head><title>PHP MapScript Hello World</title></head>
> <body>
> <form action="hello.php" method="POST">
>     <input type="image" name="img"
>         src="c:/ms4w/tmp/ms_tmp/<?php echo $image_name; ?>">
> </form>
> </body>
> </html>
> 
> _The map file:_
> 
> # "Hello World" mapfile
> NAME "Hello World"
> SIZE 400 300
> IMAGECOLOR 249 245 186
> IMAGETYPE png
> EXTENT -1.0 -1.0 1.0 1.0
> WEB
>      IMAGEPATH "c:/ms4w/tmp/ms_tmp/tmp/"
>      IMAGEURL "/tmp/"
> END
> LAYER                     
>      STATUS default
>      TYPE point
>      FEATURE
>           POINTS  0.00 0.00 END
>           TEXT "Hello World"
>      END # end feature
>      CLASS
>           STYLE
>                COLOR 255 0 0
>           END
>           LABEL
>                TYPE bitmap
>           END
>      END
> END
> END
> 
> 

here are some comments:


- MS4W is pre-configured for the following settings:

   IMAGEPATH "/ms4w/tmp/ms_tmp/"
   IMAGEURL  "/ms_tmp/"

Make sure to use those settings in all of your MS4W mapfiles.

- you can test that your mapfile generates a map image properly by using 
the shp2img commandline utility, that is included in MS4W 
(http://mapserver.gis.umn.edu/docs/reference/utilityreference/shp2img)

- MS4W also comes with a small PHP file that can generate a map image 
(see /ms4w/Apache/htdocs/quickmap.php)

-- 
Jeff McKenna
FOSS4G Consulting and Training Services
http://www.gatewaygeomatics.com/





More information about the MapServer-users mailing list