[mapserver-users] Need help: How to make drawn layer visible?
Jan Mantkowski
jan.mantkowski at gmx.de
Thu Mar 21 23:16:56 PST 2002
Dear all,
i have rebuild the php script and the mapfile and sortet out a lot of
errors.
But i am still unshure how to make the dynamically drawn layer to appear?
Please have a look at my phpscript and the according mapfile.
Thank you all,
Jan
At the screen right now i get this:
Map name=FIRSTMAP, num lay=2
Layer num=0, name=world
Layer num=1, name=users
2500000 -4000000 Jan
8000000 1000000 Jose
4000000 3000000 Madeleine
2000000 4000000 Fritz
And a map showing europe.
php script:
<?php
dl("php_mapscript_35.dll");
$map = ms_newMapObj("europe.map");
$layerName="users";
printf("Map name=%s, num lay=%d<br>\n", $map->name, $map->numlayers);
for ($i=0; $i<$map->numlayers; $i++) {
$myLayer = $map->getLayer($i);
printf("Layer num=%d, name=%s <br>\n", $i, $myLayer->name);
}
echo"<br>";
//mysql_q
$db = mysql_connect("localhost", "root", "");
mysql_select_db("Rogue",$db);
$results = mysql_query("SELECT * FROM nuke_map",$db);
if ($results === false) die("failed");
//display result of mysql query on screen
while ($show = mysql_fetch_array($results, MYSQL_ASSOC)) {
echo
$show["pn_lon"]." ".$show["pn_lat"]." &nbs
p; ".$show["pn_name"]."<br>\n";
}
//drawPoints
$layer = $map->getLayerByName( $layerName );
// Loop through result of point query and:
while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) {
$pt = ms_newPointObj();
$pt->setXY( $line["pn_lon"], $line["pn_lat"] );
$pt->draw($map, $layer, $image, 0, "TEST");
$layer->set('status', MS_ON);
$layer->draw($image);
}
// ende
$img = $map->draw();
$url = $img->saveWebImage(MS_PNG, 0, 0, 0);
printf("<IMG border=1 SRC=%s WIDTH=%d HEIGHT=%d>\n", $url, $map->width,
$map->height);
?>
europe.map:
NAME FIRSTMAP
SIZE 400 400
STATUS ON
EXTENT -5696501 1923039 5696501 11022882
UNITS METERS
WEB
IMAGEPATH "c:\Apache\htdocs\tmp\"
IMAGEURL "/tmp/"
END
LAYER
NAME world
TYPE POLYGON
STATUS ON
DATA europa
CLASS
TEMPLATE void
COLOR 110 50 100
OUTLINECOLOR 200 200 200
#END
END
TOLERANCE 10
END
LAYER
NAME "users"
STATUS ON
TYPE ANNOTATION
LABELITEM "text"
CLASS
COLOR -1 -1 -1 # no marker will be drawn
LABEL
SIZE MEDIUM
COLOR 132 31 31
OUTLINECOLOR 255 255 255
BUFFER 4
END
END
END
END
More information about the MapServer-users
mailing list