Solution: RE: [UMN_MAPSERVER-USERS] Layer working in mapfile, not (fully) working within PHP
Hoeven, Maarten van der
Maarten.van.der.Hoeven at KNMI.NL
Wed Jun 29 08:37:07 PDT 2005
I found the solution for my problem; this to inform the list (and other
with an alike problem).
The code is okay, I had to add the following to get the labels displayed
on the map
$layerObj1->set("labelcache",MS_OFF);
That's all :)
Maarten
-----Oorspronkelijk bericht-----
Van: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]
Namens Hoeven, Maarten van der
Verzonden: Tuesday, June 28, 2005 4:07 PM
Aan: MAPSERVER-USERS at LISTS.UMN.EDU
Onderwerp: [UMN_MAPSERVER-USERS] Layer working in mapfile, not (fully)
working within PHP
Re-sending (might be missed because I send it during the weekend. My
apologies if my re-sending seems pushy)
===
Hi list,
thanks for all your help; all suggestions are most useful!
My problem is, when I use the layer-definition from the mapfile, the
countries as well as the country names are displayed. However, when I
dynamically build my layer in PHP (commenting out the whole
'country_name' layer-definition in the mapfile, of course), the
countries are displayed okay, but the country names are *not* displayed
at all. I do want to display the country names from the layer I defined
in the PHP script.
Any guru can see what's wrong?
All the best,
Maarten
=== mapfile ===
LAYER
NAME country_name
METADATA
"RESULT_FIELDS" "CNTRY_NAME"
END
TYPE POLYGON
STATUS ON
DATA country_eca
LABELITEM 'CNTRY_NAME'
CLASSITEM 'CNTRY_NAME'
CLASS
NAME 'CNTRY_NAME'
STYLE
OUTLINECOLOR 0 0 0
COLOR 255 255 191
END
LABEL
POSTLABELCACHE TRUE
MINFEATURESIZE 40
POSITION CC
PARTIALS FALSE
COLOR '#000080'
SIZE GIANT
END
END
END # layer
=== php script (part of it) ===
$layerObj1 = ms_newLayerObj($gpoMap);
$layerObj1->set("name","country_name");
$layerObj1->set("type",MS_LAYER_POLYGON);
$layerObj1->set("status",MS_ON);
$layerObj1->set("data","country_eca");
$layerObj1->set("labelitem","cntry_name");
$layerObj1->set("classitem","cntry_name");
$layerObj1->setMetaData("result_fields","cntry_name");
$classObj1 = ms_newClassObj($layerObj1);
$classObj1->set("name","cntry_name");
$styleObj1 = ms_newStyleObj($classObj1);
$styleObj1->color->setRGB(255,255,191);
$styleObj1->outlinecolor->setRGB(0,0,0);
$classObj1->label->set("size",MS_GIANT);
$classObj1->label->set("position",MS_CC);
$classObj1->label->set("minfeaturesize",40);
$classObj1->label->set("partials",MS_FALSE);
$classObj1->label->color->setRGB(0,0,80);
$layerObj1->draw($img);
More information about the MapServer-users
mailing list