Create a polygon layer using PHPMAPSCRIPT

Delfos, Jacob Jacob.Delfos at MAUNSELL.COM
Thu Oct 5 19:33:25 EDT 2006


Hi Murat,

A few potential reasons why it might not work:

Your expression does not have quotes around the value:

$class->setExpression("'[ilce_ad]' EQ $ilceadi");
Maybe make it:
$class->setExpression("'[ilce_ad]' EQ '".$ilceadi."'");

If you only class on one attribute, you could set a class item, and make
the expression:
$class->setExpression($ilceadi);

Another possible reason is that you may not save your mapfile, so your
dynamic layer isn't saved in it. You can save it like:
$oMap->save("c:/mapfile.map");

If you are using PHP sessions, you may need to save the state of your
session instead. Try this, and see what ends up being written to your
mapfile by opening it.

Hope this helps...

Jacob




> -----Original Message-----
> From: UMN MapServer Users List 
> [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On Behalf Of Murat BEYHAN
> Sent: 5 October 2006 21:28
> To: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: [UMN_MAPSERVER-USERS] Create a polygon layer using 
> PHPMAPSCRIPT
> 
> Dear Friends;
> I would like to make a polygon layer by using phpmapscript.
> By the following php code code its not create any error.
> But the layer could not be vieved on the map.
> Actually I would like to make an expression that only one 
> border of the
> district will be drawn on the map since you selected the name 
> of the district
> from the database and there are two way to draw layer of the 
> polygon, one is
> to send the name of the district to the map and onether is 
> create the layer
> for that district on php. Am I rigth?
> I really don't have any idea which way is acceptable for 
> that. On the map file
> the layer for the whole districts already drawn by the following
> 
> LAYER # ilceler
>                 NAME district
>                 DATA tr_ilce_siniri_dd
>                 STATUS on
>                 TYPE LINE
>                 CLASSITEM "ILCE_AD"
>                 CLASS
>                 NAME "ILCE SINIRLARI"
> ###                expression ('[il_adi]' eq '$iladi)
>                  COLOR 211 211 211
>                 OUTLINECOLOR 230 230 250
>                 END # end of States class object
>                 END # end of layer object     
> 
> But I would like to draw a district highlighted on the map in 
> order to see
> easily than other district.
> By using expression it is easy but The name of the district 
> will be a variable
> on php. Users on the net for accessing to draw their 
> district. The name of the
> district comes to php code as $iladi by querying mysql select 
> expression.then
> the name of the district will be hihglighted on the map.
> 
> I have tried the following but I couldn't construct how I 
> will create polygone
> layer on the php mapscript
> any idea will be appreciated...
> Thankyou
> Murat
> 
> $layer = ms_newLayerObj($map);
>         $layer->set("name", "polygon");
> 	$layer->set("data", "tr_ilce_siniri_dd");
> 	
>         $layer->set("type", MS_LAYER_POLYGON);
>         $layer->set("status", MS_ON);
> 
>         $class = ms_newClassObj($layer);
>         $class->set("status", MS_ON);
> 	$class->setExpression("'[ilce_ad]' EQ $ilceadi");
>         $class->label->set("type", MS_TRUETYPE);
>         $class->label->set("font", 'arial');
>         $class->label->color->setRGB( 200,200,200);
>         $class->label->outlinecolor->setRGB(255, 255, 255);
>         $class->label->set("size", 12);
>         $class->label->set("position", 9);
> 
>         $style = ms_newStyleObj($class);
>         $style->set("symbol", $map->getsymbolbyname( 'cline'));
>         $style->set("size", 8);
>         $style->color->setRGB( 200,200,200);
>         $style->outlinecolor->setRGB(255, 255, 255);
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> 



More information about the mapserver-users mailing list