[mapserver-users] Values from Db not appearing on Map
NVohra at eq-technologic.com
NVohra at eq-technologic.com
Sat Jun 8 00:50:31 PDT 2002
Hello,
I am using MapServer PHP MapScript Module, which i picked from
DMSolutions site.
I am trying to display points on the map from a db. Atmost only one
value appears on
the map and that also not always.
Is there any problem with scale factor? Is it not possible to have a
layer without
any shapefile as data and just displaying labels?
My map file looks like this:
#-------*****-----
NAME DEMO
STATUS ON
SIZE 1000 550
EXTENT 70 20 95 33
UNITS DD
FONTSET "C:\Program Files\Apache
Group\APACHE\htdocs\itasca\php\fontsw.list"
SHAPEPATH "C:\Program Files\Apache Group\APACHE\htdocs\itasca\data"
IMAGECOLOR 255 255 255
WEB
HEADER demo_header.html
TEMPLATE demo.html
FOOTER demo_footer.html
MINSCALE 1000
MAXSCALE 1550000
IMAGEPATH "c:\tmp\"
IMAGEURL "c:\tmp\"
# LOG "demo.log"
END
LAYER
NAME test
TYPE POINT
DATA rdline2
STATUS ON
LABELCACHE on
CLASS
NAME ptclass
OUTLINECOLOR 255 89 89
COLOR 255 136 136
LABEL
FONT arial
TYPE truetype
SIZE 10
COLOR 0 0 255
OUTLINECOLOR 199 216 252
POSITION auto
FORCE true
END
END
END
END # Map File
#-------*****-----
And my php file looks like this :
#-------*****-----
$conn = odbc_connect("pgdsn","test","test") or die ("Couldn't connect to
the db");
$sql = "select latitude,longitude from loctbl";
$sql_stmt = odbc_prepare($conn, $sql) or die ("Could not prepare stmt");
$sql_result = odbc_exec($conn, $sql) or die ("execute failed");
$rowcnt = odbc_num_rows($sql_result);
$i = 0;
while ($i < $rowcnt)
{
odbc_fetch_row($sql_result, $i);
$row[0] = odbc_result($sql_result, 1);
$row[1] = odbc_result($sql_result, 2);
$points[$i] = $row;
$i = $i + 1;
}
odbc_free_result($sql_result);
odbc_close($conn);
$map = ms_newMapObj("demo.map");
$image=$map->draw();
$layerObj = $map->getLayerByName('test');
$classObj = $layerObj->getClass(0);
$i = 0;
while ($i < $rowcnt)
{
$row = $points[$i];
$pointObj = ms_newPointObj();
$pointObj->x = $row[0];
$pointObj->y = $row[1];
$pointObj->draw($map, $layerObj, $image, "ptclass", "V");
$i = $i + 1;
}
$map->drawLabelCache($image);
$image_url=$image->saveWebImage(MS_PNG,1,1,0);
#-------*****-----
Nischal Vohra
More information about the MapServer-users
mailing list