[mapserver-users] PHP, Create Layer on Fly - HELP

Hankley, Chip Chip.Hankley at GASAI.Com
Fri Sep 28 16:33:18 EDT 2001


OK, I'm totally lost. I'm trying to embed a legend into my map. I've created
a PNG of my legend, and I want it to always render at the LL of my image.
What I'm trying to do is create a point layer on the fly, using the PNG
image as my symbol.

I'm getting a couple of PARSE errors...lines 18 and 22, that are befuddling
me.

If I just comment these out, I get the following fatal error:

Fatal error: Object has an invalid '_map_handle_' property in
c:\inetpub\wwwroot\seating\seating.php on line 42

I feel like I'm misreading the 3.5 PHP docs somehow.

Any help, as always, is much appreciated.

Chip

Here's the snippets of code:

1   $img = $map->draw();
2   embed_legend($map, $Cur_Extent, $img);
3   
4   function embed_legend($map, $Cur_Extent, $img) {
5     //$map is the current MapObject
6     //$Cur_Extent is an array where:
7       //$Cur_Extent[0] = Xmin
8       //$Cur_Extent[1] = Ymin
9       //$Cur_Extent[2] = Xmax
10      //$Cur_Extent[3] = Ymax
12    //$img is the current ImageObject
13 
14   //Create a new Point Layer
15   $layer = ms_newLayerObj($map);
16   $layer->set("name", "legend");
17   $layer->set("type", MS_LAYER_POINT);
18   $layer->set{"status", 1); //THIS GIVES ME A PARSE ERROR
19 
20   //Create a new Class for the Layer
21   $class = ms_newClassObj($layer);
22    $class->set{"name", "legendclass");  //THIS GIVES ME A PARSE ERROR
23    $symb = $map->getSymbolByName('symbols/legend.png');
24    $class->set("symbol", $symb);
25  
26    //Place the point so that it is 52 pixels IN and 41
27    // pixels UP from the lower left hand conrner of
28    // the image. We are using an image that is 100 x 80
29    // pixels... this should put the image just inside
30    // the rendered image.
31    $ImgWidth = $map->width;
32    $ImgHeight = $map->height;
33    $Pixel_X = ($Cur_Extent[2] - $Cur_Extent[0]) / $ImgWidth;
34    $Pixel_Y = ($Cur_Extent[3] - $Cur_Extent[1]) / $ImgHeight;
35    $Spot_X = $Cur_Extent[0] + 52 * $Pixel_X;
36    $Spot_Y = $Cur_Extent[1] + 41 * $Pixel_Y;
37    
38    $point = ms_newpointObj();
39    $point->setXY($Spot_X, $Spot_Y);
40    $point->draw($map,$layer,$img,'legendclass',undef);
41  
42    $layer->draw($img);
43  }




More information about the mapserver-users mailing list