[mapserver-users] drawing layer with user names from mysql table
Dan Barron
dbarron at ddive.com
Wed Mar 20 08:32:30 PST 2002
Jan,
Verify that you have "PNUsers" defined as a layer in your
c:/Apache/htdocs/pn_71/html/modules/map/data/europe.map" file. Like
LAYER
NAME 'PNUsers'
...
END
Dan
At 01:34 PM 3/20/2002 +0000, Jan Mantkowski wrote:
>Steve,
>i had that error befor. Should have know better.
>
>I fixed it by adding this line:
>$map
>=ms_newMapObj("c:/Apache/htdocs/pn_71/html/modules/map/data/europe.map");
>
>The only thing that changed is the error message:
>
>Warning: MapServer Error in : in
>c:\apache\htdocs\pn_71\html\modules\map\index-standalone3.php on line 29
>Fatal error: getLayerByName failed for : PNUsers in
>c:\apache\htdocs\pn_71\html\modules\map\index-standalone3.php on line 29
>
>line 29 still is: $layer = $map->getLayerByName( $layerName );
>
>And now? Anny suggstions?
>
>Thanks,
>Jan
>
>
>This is the dump of the mysql table:
>
>CREATE TABLE nuke_map (
> pn_name varchar(20) NOT NULL default '',
> pn_lat varchar(15) NOT NULL default '',
> pn_lon varchar(15) NOT NULL default '',
> PRIMARY KEY (pn_name)
>) TYPE=MyISAM;
>
># Dumping data for table `nuke_map`
>
>INSERT INTO nuke_map VALUES ('Jan London', '51.5063', '-0.1271');
>INSERT INTO nuke_map VALUES ('Jose Madrid', '40.4203', '-3.7057');
>INSERT INTO nuke_map VALUES ('Madeleine Paris', '48.8547', '2.3453');
>INSERT INTO nuke_map VALUES ('Fritz Hamburg', '53.5548', '9.9898');
>
>
>This is the whole code:
>
><?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");
>
>//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);
> }
>
>//showmap
>$map = ms_newMapObj("data/europe.map");
>$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