4.24.
SymbolObj
Up one level
Constructor, members, and methods.
- Constant names and class member variable names are case-sensitive in PHP.
- Several MapScript functions (all those that access files in the back end such as ms_newMapObj(), drawMap(), etc.) will affect the value of the current working directory (CWD) in the PHP environment. This will be fixed eventually but in the meantime you should be careful about these side-effects.
Constructor:
symboldid = ms_newSymbolObj(mapObj map, string symbolname);
Creates a new symbol with default values in the symbolist.
Returns the Id of the new symbol. If a symbol with the same
name exists, It's id will be returned.
To get a symbol object, you need to use a method on the map object:
$oSymbol = $map->getSymbolObjectById($nId);
Members:
string name;
type name; //Please refer to symbol type constants
int inmapfile; If set to TRUE, the symbol will be saved inside
the mapfile.
double sizex;
double sizey
int numpoints (Read-Only)
int filled;
int patternlength; (Read-Only)
int stylelength; (Deprecated in v5.0, use patternlength instead.) (Read-Only)
string imagepath; (Read-Only))
int transparent;
int transparentcolor;
string character;
int antialias;
string font;
int gap;
int position;
Methods:
int set(string property_name, new_value)
Set object property to a new value.
int setpoints(array double)
Set the points of the symbol. Note that the values passed if an
array containing the x and y values of the points. Example
array[0] = 1 : x value of the first point
array[1] = 0 : y values of the first point
array[2] = 1 : x value of the 2nd point
....
int setpattern(array int)
Set the pattern of the symbol (used for dash patterns)
array getpointsarray()
Returns an array containing the points of the symbol. Refer
to setpoints to see how the array should be interpreted.
array getpatternarray()
Returns an array containing the pattern.
int setimagepath(char filename)
Loads a pixmap symbol specified by the filename.
The file should be of either Gif or Png format.
int setstyle(array int)
Deprecated in v5.0, will be removed in a future release.
Use setpattern() instead.
array getstylearray()
Deprecated in v5.0, will be removed in a future release.
Use getpatternarray() instead.
Example of usage:
1- crete a symbol to be used as a dash line
$nId = ms_newsymbolobj($gpoMap, "mydash");
$oSymbol = $gpoMap->getsymbolobjectbyid($nId);
$oSymbol->set("filled", MS_TRUE);
$oSymbol->set("sizex", 1);
$oSymbol->set("sizey", 1);
$oSymbol->set("inmapfile", MS_TRUE);
$aPoints[0] = 1;
$aPoints[1] = 1;
$oSymbol->setpoints($aPoints);
$aPattern[0] = 10;
$aPattern[1] = 5;
$aPattern[2] = 5;
$aPattern[3] = 10;
$oSymbol->setpattern($aPattern);
$style->set("symbolname", "mydash");
2- Create a TrueType symbol
$nId = ms_newSymbolObj($gpoMap, "ttfSymbol");
$oSymbol = $gpoMap->getSymbolObjectById($nId);
$oSymbol->set("type", MS_SYMBOL_TRUETYPE);
$oSymbol->set("filled", true);
$oSymbol->set("character", "D");
$oSymbol->set("font", "ttfFontName");