adding label to point layer in PHPMapscript

Delfos, Jacob Jacob.Delfos at MAUNSELL.COM
Tue Sep 26 01:04:33 PDT 2006


Murat,
 
Are you sure you want all your villages to have the same label
($villagename)?
I think you may want to define a labelitem:
 
$point_layer->set("labelitem","villagename"); // "villagename" is the
name of the attribute of the layer
 
Also, you quoted "$koyadi", which is probably not correct. Or remove the
'$'.
 
Have you tested whether any part of this code works? Which part is
giving you trouble? Does your PHP log say anything?
 
regards,
 
Jacob
 


________________________________

	From: UMN MapServer Users List
[mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On Behalf Of Murat BEYHAN
	Sent: 26 September 2006 15:56
	To: MAPSERVER-USERS at LISTS.UMN.EDU
	Subject: [UMN_MAPSERVER-USERS] adding label to point layer in
PHPMapscript
	
	
	Dear Friends, 
	
	I'have draw point layer by using php. That point only one in the
map. 
	Now I would like to make label for that point as $villagename 
	I have tried following codes but I think something wrong. 
	Could you help me What is my mistake... 
	Regards 
	Murat 
	$villagename='kanamura'; 
	 $map_path="/var/www/html/zone/"; 
	 $map = ms_newMapObj($map_path."zone.map"); 
	 $map->setExtent($nMinX, $nMinY, $nMaxX, $nMaxY); 
	  
	// create a temp layer to hold our points 
	$point_layer = ms_newLayerObj($map); 
	$point_layer->set("name", "$koyadi"); 
	$point_layer->set("type", MS_LAYER_POINT); 
	$point_layer->set("status", MS_DEFAULT); 
	$point_layer->setProjection("proj=latlong",MS_TRUE); 
	
	// create a class and style for this layer 
	$point_class = ms_newClassObj($point_layer); 
	$point_style = ms_newStyleObj($point_class); 
	$point_symbol = $map->getSymbolByName("cpoint"); 
	
	$point_style->set("symbol", $point_symbol); 
	$point_style->set("size", 12); 
	$point_style->color->setRGB(255,0,255); 
	$point_style->outlinecolor->setRGB(255,255,0); 
	
	$label = $point_class->label; 
	$label->set("position", MS_CC); 
	$label->set("font","sans"); 
	$label->set("type",MS_TRUEYPE); 
	$label->set("size",MS_MEDIUM); 
	$label->color->setRGB(22,8,3); 
	$label->backgroundcolor->setRGB(0,0,0); 
	$label->set(minsize,4); 
	$label->set(maxsize,100000); 
	
	// draw our image without the points 
	 $ref = $map->drawreferencemap(); 
	 $legend=$map->drawLegend(); 
	
	$image = $map->draw(); 
	
	// initialize our point and add it to the map 
	$point = ms_newPointObj(); 
	$longitude=$lon;// comes from select queries from mysql as a
result 
	$latitude=$lat;// comes from select queries from mysql as a
result 
	
	$point->setXY($longitude, $latitude); 
	$point->draw($map, $point_layer, $image, 0, ""); 
	  $map_url=$image->saveWebImage(); 
	  $ref_url = $ref->saveWebImage(); 
	  $legend_url=$legend->saveWebImage();  
	
	-- 
	This message has been scanned for viruses and 
	dangerous content by MailScanner <http://www.mailscanner.info/>
, and is 
	believed to be clean. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060926/6344e26f/attachment.htm>


More information about the MapServer-users mailing list