[mapserver-users] phpmapscript with postgis
Sam Young
samnyoung at hotmail.com
Thu Jun 19 09:58:48 PDT 2008
I am trying to develop a map application with php mapscript and postgis. I can map my postgis data in a standard map file and the php mapscript generates a map file on a shape file. However, when I try to generate a php mapscript map I get a blank screen. There are no error messages but the data doesn't display. My php file is shown below. Does anyone have any suggestions?
Thanks,
Sam
<html>
<head></head>
<body>
<?PHP
// ex5_map_points.php
// Load MapScript extension
if (!extension_loaded("MapScript"))
dl('php_mapscript.'.PHP_SHLIB_SUFFIX);
// Create a map object. Provide empty string if not
// using an existing map file
$oMap = ms_newMapObj("");
// Set size of the output map image
$oMap->setSize(256,256);
$oMap->web->set(imagepath,"/ms4w/tmp/ms_tmp/");
$oMap->web->set(imageurl,"/ms_tmp/");
// Set the geographic extents of the map.
$oMap->setExtent(1543790,718550,1560340,750790);
// Create a data layer and associate it with the map.
// This is the raster layer showing some cloud imagery
$oLayerRoads = ms_newLayerObj($oMap);
$oLayerRoads->set( "name", "roads");
$oLayerRoads->set( "type", MS_LAYER_LINE);
$oLayerRoads->set( "status", MS_DEFAULT);
$oLayerRoads->set( "connectiontype", "postgis");
$oLayerRoads->set( "connection", "dbname=gisdb user=user password=password host=localhost port=5432");
$oLayerRoads->set( "data", "the_geom from (select * from roads) as foo using unique gid using SRID=2242");
// Create a class object to set feature drawing styles.
$oMapClass = ms_newClassObj($oLayerRoads);
// Create a style object defining how to draw features
$oRoadsStyle = ms_newStyleObj($oMapClass);
$oRoadsStyle->color->setRGB(255,0,0);
// Create label settings for drawing text labels
$oMapClass->label->set( "position", MS_AUTO);
$oMapClass->label->color->setRGB(250,0,0);
$oMapClass->label->outlinecolor->setRGB(255,255,255);
// Render the map into an image object
$oMapImage = $oMap->draw();
$image_url=$oMapImage->saveWebImage();
?>
<img src=<?php echo $image_url; ?> alt="Map" />
</body>
</html>
_________________________________________________________________
Need to know now? Get instant answers with Windows Live Messenger.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_062008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080619/0989bd20/attachment.htm>
More information about the MapServer-users
mailing list