[mapserver-users] drawing layer with user names from mysql table UPDATE
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Mar 20 09:02:31 PST 2002
Great your making progress.
Now you need to read the posts over the last two/three days with the
subject "Drawing features dynamically" which explains exactly how to do
what you are asking.
http://mapserver.gis.umn.edu/cgi-bin/wilma/mapserver-users
-Steve
Jan Mantkowski wrote:
>
> Hi Steve, Dan, List,
>
> i did some work in the meantime:
>
> I get this right now:
>
> Map name=FIRSTMAP, num lay=3
> Layer num=0, name=world
> Layer num=1, name=Nations
> Layer num=2, name=PNUsers
>
> -0.1271 51.5063 Jan London
> -3.7057 40.4203 Jose Madrid
> 2.3453 48.8547 Madeleine Paris
> 9.9898 53.5548 Fritz Hamburg
>
> and a map exactly as in the original europe example.
>
> So what to do to display the users?
>
> Jan
>
> 1) I replaced the PNUser layer with a copy of the nations layer.
>
> I only changed two lines:
>
> LAYER
> NAME "PNUsers"
> DATA users
>
> My php script now looks like this:
> Can it be, that $image is used for 2 completely different things, and the
> second one replaces the results of the first one?
>
> <?php
>
> // load .dll`s, so there is no need to edit the php.ini.
> // but you need to put this files in your /php/extensions folder
>
> dl("php_mapscript_35.dll");
> dl("php_proj.dll");
> dl("php_dbase.dll");
>
> //variables
>
> GLOBAL $map;
> GLOBAL $image;
> GLOBAL $layer;
> $layerName="PNUsers";
>
> $map
> =ms_newMapObj("c:/Apache/htdocs/pn_71/html/modules/map/data/europe.map");
>
> 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);
>
> }
>
> //show it altogether
> $image=$map->draw();
> $layer->draw($image);
> $image_url=$image->saveWebImage(MS_PNG,1,1,0);
> echo "<img src=\"".$image_url."\">";
> ?>
More information about the MapServer-users
mailing list