.. _php_mapscript: ***************************************************************************** PHP MapScript ***************************************************************************** :Author: Daniel Morissette :Contact: dmorissette at mapgears.com :Author: Yewondwossen Assefa :Contact: yassefa at dmsolutions.ca :Author: Alan Boudreault :Contact: aboudreault at mapgears.com :Revision: $Revision$ :Date: $Date$ .. note:: If you are using MapServer 5.6 and older, please refer to the :ref:`PHP MapScript 5.6 documentation ` instead. .. note:: If you are migrating your existing application that is based on MapServer 5.6 or older, to MapServer 6.0 or beyond, please read the :ref:`PHP MapScript Migration Guide ` for important changes. .. contents:: :depth: 3 :backlinks: top .. index:: pair: MapScript; PHP Introduction ------------ This is a `PHP `_ module that makes MapServer's MapScript functionalities available in a PHP Dynamically Loadable Library. In simple terms, this module will allow you to use the powerful PHP scripting language to dynamically create and modify map images in MapServer. Versions Supported ------------------ PHP 5.2.0 or more recent is required; since MapServer 6.0, support for PHP 4, PHP 5.0 and PHP 5.1 have been dropped. PHP MapScript was originally developed for PHP 3.0.14, and after MapServer 3.5 support for PHP 3 was dropped. The module has been tested and used on Linux, Solaris, \*BSD, and Windows. How to Get More Information on PHP MapScript -------------------------------------------- - For installation questions regarding the PHP MapScript module, see :ref:`php_install`. - The `MapServer Wiki`_ has information on this module, that was contributed by users. - New PHP MapScript users should read the :ref:`php_example` document. - The project's home is the `PHP/MapScript page`_ on MapTools.org. - Also, see the :ref:`mapscript`, and the :ref:`mapfile` sections of this site. - Refer to the main `PHP site`_ for their official documentation. .. _`MapServer Wiki`: http://trac.osgeo.org/mapserver/wiki/PHPMapScript .. _`PHP/MapScript page`: http://www.maptools.org/php_mapscript/ .. _`PHP site`: http://www.php.net Important Note -------------- - Constant names and class member variable names are case-sensitive in PHP. .. index:: triple: MapScript; PHP; Constants Constants --------- The following MapServer constants are available: Boolean values MS_TRUE, MS_FALSE, MS_ON, MS_OFF, MS_YES, MS_NO Map units MS_INCHES, MS_FEET, MS_MILES, MS_METERS, MS_KILOMETERS, MS_DD, MS_PIXELS, MS_NAUTICALMILES Layer types MS_LAYER_POINT, MS_LAYER_LINE, MS_LAYER_POLYGON, MS_LAYER_RASTER, MS_LAYER_ANNOTATION, MS_LAYER_QUERY, MS_LAYER_CIRCLE, MS_LAYER_TILEINDEX, MS_LAYER_CHART Layer/Legend/Scalebar/Class Status MS_ON, MS_OFF, MS_DEFAULT, MS_EMBED, MS_DELETE Layer alpha transparency allows alpha transparent pixmaps to be used with RGB map images MS_GD_ALPHA Font types MS_TRUETYPE, MS_BITMAP Label positions MS_UL, MS_LR, MS_UR, MS_LL, MS_CR, MS_CL, MS_UC, MS_LC, MS_CC, MS_XY, MS_AUTO, MS_AUTO2, MS_FOLLOW, MS_NONE Bitmap font styles MS_TINY , MS_SMALL, MS_MEDIUM, MS_LARGE, MS_GIANT Shape types MS_SHAPE_POINT, MS_SHAPE_LINE, MS_SHAPE_POLYGON, MS_SHAPE_NULL Shapefile types MS_SHP_POINT, MS_SHP_ARC, MS_SHP_POLYGON, MS_SHP_MULTIPOINT Query/join types MS_SINGLE, MS_MULTIPLE Querymap styles MS_NORMAL, MS_HILITE, MS_SELECTED Connection Types MS_INLINE, MS_SHAPEFILE, MS_TILED_SHAPEFILE, MS_SDE, MS_OGR, MS_TILED_OGR, MS_POSTGIS, MS_WMS, MS_ORACLESPATIAL, MS_WFS, MS_GRATICULE, MS_RASTER, MS_PLUGIN, MS_UNION Error codes MS_NOERR, MS_IOERR, MS_MEMERR, MS_TYPEERR, MS_SYMERR, MS_REGEXERR, MS_TTFERR, MS_DBFERR, MS_GDERR, MS_IDENTERR, MS_EOFERR, MS_PROJERR, MS_MISCERR, MS_CGIERR, MS_WEBERR, MS_IMGERR, MS_HASHERR, MS_JOINERR, MS_NOTFOUND, MS_SHPERR, MS_PARSEERR, MS_SDEERR, MS_OGRERR, MS_QUERYERR, MS_WMSERR, MS_WMSCONNERR, MS_ORACLESPATIALERR, MS_WFSERR, MS_WFSCONNERR, MS_MAPCONTEXTERR, MS_HTTPERR, MS_WCSERR Symbol types MS_SYMBOL_SIMPLE, MS_SYMBOL_VECTOR, MS_SYMBOL_ELLIPSE, MS_SYMBOL_PIXMAP, MS_SYMBOL_TRUETYPE Image Mode types (:ref:`outputFormatObj `) MS_IMAGEMODE_PC256, MS_IMAGEMODE_RGB, MS_IMAGEMODE_RGBA, MS_IMAGEMODE_INT16, MS_IMAGEMODE_FLOAT32, MS_IMAGEMODE_BYTE, MS_IMAGEMODE_FEATURE, MS_IMAGEMODE_NULL Style/Attribue binding MS_STYLE_BINDING_SIZE, MS_STYLE_BINDING_ANGLE, MS_STYLE_BINDING_COLOR, MS_STYLE_BINDING_OUTLINECOLOR, MS_STYLE_BINDING_SYMBOL, MS_STYLE_BINDING_WIDTH Label/Attribute binding MS_LABEL_BINDING_SIZE, MS_LABEL_BINDING_ANGLE, MS_LABEL_BINDING_COLOR, MS_LABEL_BINDING_OUTLINECOLOR, MS_LABEL_BINDING_FONT, MS_LABEL_BINDING_PRIORITY, MS_LABEL_BINDING_POSITION, MS_LABEL_BINDING_SHADOWSIZEX, MS_LABEL_BINDING_SHADOWSIZEY Alignment MS_ALIGN_LEFT, MS_ALIGN_CENTER, MS_ALIGN_RIGHT OwsRequest MS_GET_REQUEST, MS_POST_REQUEST .. index:: triple: MapScript; PHP; Functions Functions ---------- string ms_GetVersion() Returns the MapServer version and options in a string. This string can be parsed to find out which modules were compiled in, etc. int ms_GetVersionInt() Returns the MapServer version number (x.y.z) as an integer (x*10000 + y*100 + z). (New in v5.0) e.g. V5.4.3 would return 50403. int ms_iogetStdoutBufferBytes() Writes the current buffer to stdout. The PHP header() function should be used to set the documents's content-type prior to calling the function. Returns the number of bytes written if output is sent to stdout. See :ref:`mapscript_ows` for more info. void ms_iogetstdoutbufferstring() Fetch the current stdout buffer contents as a string. This method does not clear the buffer. void ms_ioinstallstdinfrombuffer() Installs a mapserver IO handler directing future stdin reading (ie. post request capture) to come from a buffer. void ms_ioinstallstdouttobuffer() Installs a mapserver IO handler directing future stdout output to a memory buffer. void ms_ioresethandlers() Resets the default stdin and stdout handlers in place of "buffer" based handlers. void ms_iostripstdoutbuffercontenttype() Strip the Content-type header off the stdout buffer if it has one, and if a content type is found it is return. Otherwise return false. array ms_TokenizeMap(string map_file_name) Preparses a mapfile through the MapServer parser and return an array with one item for each token from the mapfile. Strings, logical expressions, regex expressions and comments are returned as individual tokens. .. index:: triple: MapScript; PHP; Classes Classes ------- The following class objects are available through PHP MapScript. .. index:: triple: MapScript; PHP; classObj classObj ^^^^^^^^ Constructor ............................................................................... Class Objects can be returned by the `layerObj`_ class, or can be created using: .. code-block:: php new classObj(layerObj layer [, classObj class]) or using the old constructor .. code-block:: php classObj ms_newClassObj(layerObj layer [, classObj class]) The second argument class is optional. If given, the new class created will be a copy of this class. Members ............................................................................... =============== ================ =============================================== Type Name Note =============== ================ =============================================== string group string keyimage labelObj label double maxscaledenom hashTableObj metadata double minscaledenom string name int numstyles read-only int status MS_ON, MS_OFF or MS_DELETE string template string title int type =============== ================ =============================================== Methods ............................................................................... imageObj createLegendIcon(int width, int height) Draw the legend icon and return a new imageObj. int deletestyle(int index) Delete the style specified by the style index. If there are any style that follow the deleted style, their index will decrease by 1. int drawLegendIcon(int width, int height, imageObj im, int dstX, int dstY) Draw the legend icon on im object at dstX, dstY. Returns MS_SUCCESS/MS_FAILURE. void free() Free the object properties and break the internal references. Note that you have to unset the php variable to free totally the resources. string getExpressionString() Returns the :ref:`expression ` string for the class object. int getMetaData(string name) Fetch class metadata entry by name. Returns "" if no entry matches the name. Note that the search is case sensitive. .. note:: getMetaData's query is case sensitive. styleObj getStyle(int index) Return the style object using an index. index >= 0 && index < class->numstyles. string getTextString() Returns the text string for the class object. int movestyledown(int index) The style specified by the style index will be moved down into the array of classes. Returns MS_SUCCESS or MS_FAILURE. ex class->movestyledown(0) will have the effect of moving style 0 up to position 1, and the style at position 1 will be moved to position 0. int movestyleup(int index) The style specified by the style index will be moved up into the array of classes. Returns MS_SUCCESS or MS_FAILURE. ex class->movestyleup(1) will have the effect of moving style 1 up to position 0, and the style at position 0 will be moved to position 1. int removeMetaData(string name) Remove a metadata entry for the class. Returns MS_SUCCESS/MS_FAILURE. int set(string property_name, new_value) Set object property to a new value. int setExpression(string expression) Set the :ref:`expression ` string for the class object. int setMetaData(string name, string value) Set a metadata entry for the class. Returns MS_SUCCESS/MS_FAILURE. int settext(string text) Set the text string for the class object. int updateFromString(string snippet) Update a class from a string snippet. Returns MS_SUCCESS/MS_FAILURE. .. code-block:: php /*set the color */ $oClass->updateFromString('CLASS STYLE COLOR 255 0 255 END END'); .. index:: triple: MapScript; PHP; clusterObj clusterObj ^^^^^^^^^^^^ Constructor ............................................................................... Instance of clusterObj is always embedded inside the `layerObj`_. Members ............................................................................... =============== ================================================================ Type Name =============== ================================================================ double buffer double maxdistance string region =============== ================================================================ Methods ............................................................................... string getFilterString() Returns the :ref:`expression ` for this cluster filter or NULL on error. string getGroupString() Returns the :ref:`expression ` for this cluster group or NULL on error. int setFilter(string expression) Set layer filter :ref:`expression `. int setGroup(string expression) Set layer group :ref:`expression `. .. index:: triple: MapScript; PHP; colorObj colorObj ^^^^^^^^ Constructor ............................................................................... Instances of colorObj are always embedded inside other classes. Members ............................................................................... =============== ================================================================ Type Name =============== ================================================================ int red int green int blue =============== ================================================================ Methods ............................................................................... void setRGB(int red, int green, int blue) Set red, green, blue values. .. index:: triple: MapScript; PHP; errorObj errorObj ^^^^^^^^ Instances of errorObj are created internally by MapServer as errors happen. Errors are managed as a chained list with the first item being the most recent error. The head of the list can be fetched using ms_GetErrorObj(), and the list can be cleared using ms_ResetErrorList() Functions ............................................................................... errorObj ms_GetErrorObj() Returns a reference to the head of the list of errorObj. void ms_ResetErrorList() Clear the current error list. Note that clearing the list invalidates any errorObj handles obtained via the $error->next() method. Members ............................................................................... =============== ================================================================ Type Name =============== ================================================================ int code //See error code constants above string message string routine =============== ================================================================ Method ............................................................................... errorObj next() Returns the next errorObj in the list, or NULL if we reached the end of the list. Example ....... This example draws a map and reports all errors generated during the draw() call, errors can potentially come from multiple layers. .. code-block:: php ms_ResetErrorList(); $img = $map->draw(); $error = ms_GetErrorObj(); while($error && $error->code != MS_NOERR) { printf("Error in %s: %s
\n", $error->routine, $error->message); $error = $error->next(); } .. index:: triple: MapScript; PHP; gridObj gridObj ^^^^^^^ Constructor ............................................................................... The grid is always embedded inside a layer object defined as a grid (layer->connectiontype = MS_GRATICULE) (for more docs : http://trac.osgeo.org/mapserver/wiki/MapServerGrid) A layer can become a grid layer by adding a grid object to it using : ms_newGridObj(layerObj layer) .. code-block:: php $oLayer = ms_newlayerobj($oMap); $oLayer->set("name", "GRID"); ms_newgridobj($oLayer); $oLayer->grid->set("labelformat", "DDMMSS"); Members ............................................................................... =============== ================================================================ Type Name =============== ================================================================ string labelformat double maxacrs double maxinterval double maxsubdivide double minarcs double mininterval double minsubdivide =============== ================================================================ Methods ............................................................................... int set(string property_name, new_value) Set object property to a new value. .. index:: triple: MapScript; PHP; hashTableObj hashTableObj ^^^^^^^^^^^^ Constructor ............................................................................... Instance of hashTableObj is always embedded inside the `classObj`_, `layerObj`_, `mapObj`_ and `webObj`_. It is uses a read only. .. code-block:: php $hashTable = $oLayer->metadata; $key = null; while ($key = $hashTable->nextkey($key)) echo "Key: ".$key." value: ".$hashTable->get($key)."
"; Methods ............................................................................... void clear() Clear all items in the hashTable (To NULL). string get(string key) Fetch class metadata entry by name. Returns "" if no entry matches the name. Note that the search is case sensitive. string nextkey(string previousKey) Return the next key or first key if previousKey = NULL. Return NULL if no item is in the hashTable or end of hashTable is reached int remove(string key) Remove a metadata entry in the hashTable. Returns MS_SUCCESS/MS_FAILURE. int set(string key, string value) Set a metadata entry in the hashTable. Returns MS_SUCCESS/MS_FAILURE. .. index:: triple: MapScript; PHP; imageObj imageObj ^^^^^^^^ Constructor ............................................................................... Instances of imageObj are always created by the `mapObj`_ class methods. Members ............................................................................... =============== =================== ============================================ Type Name Note =============== =================== ============================================ int width read-only int height read-only int resolution read-only int resolutionfactor read-only string imagepath string imageurl =============== =================== ============================================ Methods ............................................................................... void pasteImage(imageObj srcImg, int transparentColorHex [[, int dstX, int dstY], int angle]) Copy srcImg on top of the current imageObj. transparentColorHex is the color (in 0xrrggbb format) from srcImg that should be considered transparent (i.e. those pixels won't be copied). Pass -1 if you don't want any transparent color. If optional dstx,dsty are provided then it defines the position where the image should be copied (dstx,dsty = top-left corner position). The optional angle is a value between 0 and 360 degrees to rotate the source image counterclockwise. Note that if an angle is specified (even if its value is zero) then the dstx and dsty coordinates specify the CENTER of the destination area. Note: this function works only with 8 bits GD images (PNG or GIF). int saveImage([string filename, MapObj oMap]) Writes image object to specified filename. Passing no filename or an empty filename sends output to stdout. In this case, the PHP header() function should be used to set the document's content-type prior to calling saveImage(). The output format is the one that is currently selected in the map file. The second argument oMap is not manadatory. It is usful when saving to formats like GTIFF that needs georeference informations contained in the map file. On success, it returns either MS_SUCCESS if writing to an external file, or the number of bytes written if output is sent to stdout. string saveWebImage() Writes image to temp directory. Returns image URL. The output format is the one that is currently selected in the map file. .. index:: triple: MapScript; PHP; labelcacheMemberObj labelcacheMemberObj ^^^^^^^^^^^^^^^^^^^ Accessible only through the `mapObj`_ (map->getLabel()). Members ............................................................................... =============== ============== ================================================= Type Name Note =============== ============== ================================================= int classindex read-only int featuresize read-only int layerindex read-only int markerid read-only int numstyles read-only int shapeindex read-only int status read-only string text read-only int tileindex read-only =============== ============== ================================================= Method ............................................................................... None .. index:: triple: MapScript; PHP; labelcacheObj labelcacheObj ^^^^^^^^^^^^^ Accessible only through the `mapObj`_ (map->labelcache). This object is only used to give the possiblity to free the label cache (map->labelcache->freeCache()) Method ............................................................................... boolean freeCache() Free the label cache. Always returns MS_SUCCESS. Ex : map->labelcache->freeCache(); .. index:: triple: MapScript; PHP; labelObj labelObj ^^^^^^^^ Constructor ............................................................................... labelObj are always embedded inside other classes. Members ............................................................................... =============== ================================================================ Type Name =============== ================================================================ int align double angle int anglemode int antialias int autominfeaturesize colorObj backgroundcolor (deprecated since 6.0) colorObj backgroundshadowcolor (deprecated since 6.0) int backgroundshadowsizex (deprecated since 6.0) int backgroundshadowsizey (deprecated since 6.0) int buffer colorObj color string encoding string font int force int maxlength int maxsize int mindistance int minfeaturesize int minlength int minsize int numstyles int offsetx int offsety colorObj outlinecolor int outlinewidth int partials int position int priority int repeatdistance colorObj shadowcolor int shadowsizex int shadowsizey int size int type int wrap =============== ================================================================ Methods ............................................................................... int deleteStyle(int index) Delete the style specified by the style index. If there are any style that follow the deleted style, their index will decrease by 1. void free() Free the object properties and break the internal references. Note that you have to unset the php variable to free totally the resources. string getBinding(const labelbinding) Get the attribute binding for a specified label property. Returns NULL if there is no binding for this property. Example: .. code-block:: php $oLabel->setbinding(MS_LABEL_BINDING_COLOR, "FIELD_NAME_COLOR"); echo $oLabel->getbinding(MS_LABEL_BINDING_COLOR); // FIELD_NAME_COLOR styleObj getStyle(int index) Return the style object using an index. index >= 0 && index < label->numstyles. int moveStyleDown(int index) The style specified by the style index will be moved down into the array of classes. Returns MS_SUCCESS or MS_FAILURE. ex label->movestyledown(0) will have the effect of moving style 0 up to position 1, and the style at position 1 will be moved to position 0. int moveStyleUp(int index) The style specified by the style index will be moved up into the array of classes. Returns MS_SUCCESS or MS_FAILURE. ex label->movestyleup(1) will have the effect of moving style 1 up to position 0, and the style at position 0 will be moved to position 1. int removeBinding(const labelbinding) Remove the attribute binding for a specfiled style property. Example: .. code-block:: php $oStyle->removebinding(MS_LABEL_BINDING_COLOR); int set(string property_name, new_value) Set object property to a new value. int setBinding(const labelbinding, string value) Set the attribute binding for a specified label property. Example: .. code-block:: php $oLabel->setbinding(MS_LABEL_BINDING_COLOR, "FIELD_NAME_COLOR"); This would bind the color parameter with the data (ie will extract the value of the color from the field called "FIELD_NAME_COLOR" int updateFromString(string snippet) Update a label from a string snippet. Returns MS_SUCCESS/MS_FAILURE. .. index:: triple: MapScript; PHP; layerObj layerObj ^^^^^^^^ Constructor ............................................................................... Layer Objects can be returned by the `mapObj`_ class, or can be created using: .. code-block:: php layerObj ms_newLayerObj(MapObj map [, layerObj layer]) A second optional argument can be given to ms_newLayerObj() to create the new layer as a copy of an existing layer. If a layer is given as argument then all members of a this layer will be copied in the new layer created. Members ............................................................................... =============== =================== ============================================ Type Name Note =============== =================== ============================================ int annotate hashTableObj bindvals string classgroup string classitem clusterObj cluster string connection int connectiontype read-only, use setConnectionType() to set it string data int debug int dump deprecated since 6.0 string filteritem string footer gridObj grid only available on a layer defined as grid (MS_GRATICULE) string group string header int index read-only int labelcache string labelitem double labelmaxscaledenom double labelminscaledenom string labelrequires int maxfeatures double maxscaledenom hashTableObj metadata double minscaledenom string name int num_processing int numclasses read-only colorObj offsite int opacity projectionObj projection int postlabelcache string requires int sizeunits int startindex int status MS_ON, MS_OFF, MS_DEFAULT or MS_DELETE string styleitem double symbolscaledenom string template string tileindex string tileitem double tolerance int toleranceunits int transform int type =============== =================== ============================================ Methods ............................................................................... int addFeature(shapeObj shape) Add a new feature in a layer. Returns MS_SUCCESS or MS_FAILURE on error. int applySLD(string sldxml, string namedlayer) Apply the :ref:`SLD ` document to the layer object. The matching between the sld document and the layer will be done using the layer's name. If a namedlayer argument is passed (argument is optional), the NamedLayer in the sld that matchs it will be used to style the layer. See :ref:`SLD HowTo ` for more information on the SLD support. int applySLDURL(string sldurl, string namedlayer) Apply the :ref:`SLD ` document pointed by the URL to the layer object. The matching between the sld document and the layer will be done using the layer's name. If a namedlayer argument is passed (argument is optional), the NamedLayer in the sld that matchs it will be used to style the layer. See :ref:`SLD HowTo ` for more information on the SLD support. void clearProcessing() Clears all the processing strings. void close() Close layer previously opened with open(). int draw(imageObj image) Draw a single layer, add labels to cache if required. Returns MS_SUCCESS or MS_FAILURE on error. int drawQuery(imageObj image) Draw query map for a single layer. string executeWFSGetfeature() Executes a GetFeature request on a WFS layer and returns the name of the temporary GML file created. Returns an empty string on error. void free() Free the object properties and break the internal references. Note that you have to unset the php variable to free totally the resources. string generateSLD() Returns an SLD XML string based on all the classes found in the layer (the layer must have `STATUS` `on`). classObj getClass(int classIndex) Returns a classObj from the layer given an index value (0=first class) int getClassIndex(shape [, classgroup, numclasses]) Get the class index of a shape for a given scale. Returns -1 if no class matches. classgroup is an array of class ids to check (Optionnal). numclasses is the number of classes that the classgroup array contains. By default, all the layer classes will be checked. rectObj getExtent() Returns the layer's data extents or NULL on error. If the layer's EXTENT member is set then this value is used, otherwise this call opens/closes the layer to read the extents. This is quick on shapefiles, but can be an expensive operation on some file formats or data sources. This function is safe to use on both opened or closed layers: it is not necessary to call open()/close() before/after calling it. string getFilterString() Returns the :ref:`expression ` for this layer or NULL on error. array getGridIntersectionCoordinates() Returns an array containing the grid intersection coordinates. If there are no coordinates, it returns an empty array. array getItems() Returns an array containing the items. Must call open function first. If there are no items, it returns an empty array. int getMetaData(string name) Fetch layer metadata entry by name. Returns "" if no entry matches the name. Note that the search is case sensitive. .. note:: getMetaData's query is case sensitive. int getNumResults() Returns the number of results in the last query. array getProcessing() Returns an array containing the processing strings. If there are no processing strings, it returns an empty array. string getProjection() Returns a string representation of the :ref:`projection `. Returns NULL on error or if no projection is set. resultObj getResult(int index) Returns a resultObj by index from a layer object with index in the range 0 to numresults-1. Returns a valid object or FALSE(0) if index is invalid. rectObj getResultsBounds() Returns the bounding box of the latest result. shapeObj getShape(resultObj result]) If the resultObj passed has a valid resultindex, retrieve shapeObj from a layer's resultset. (You get it from the resultObj returned by getResult() for instance). Otherwise, it will do a single query on the layer to fetch the shapeindex .. code-block:: php $map = new mapObj("gmap75.map"); $l = $map->getLayerByName("popplace"); $l->queryByRect($map->extent); for ($i=0; $i<$l->getNumResults();$i++){ $s = $l->getShape($l->getResult($i)); echo $s->getValue($l,"Name"); echo "\n"; } string getWMSFeatureInfoURL(int clickX, int clickY, int featureCount, string infoFormat) Returns a WMS GetFeatureInfo URL (works only for WMS layers) clickX, clickY is the location of to query in pixel coordinates with (0,0) at the top left of the image. featureCount is the number of results to return. infoFormat is the format the format in which the result should be requested. Depends on remote server's capabilities. MapServer WMS servers support only "MIME" (and should support "GML.1" soon). Returns "" and outputs a warning if layer is not a WMS layer or if it is not queriable. boolean isVisible() Returns MS_TRUE/MS_FALSE depending on whether the layer is currently visible in the map (i.e. turned on, in scale, etc.). int moveclassdown(int index) The class specified by the class index will be moved down into the array of layers. Returns MS_SUCCESS or MS_FAILURE. ex layer->moveclassdown(0) will have the effect of moving class 0 up to position 1, and the class at position 1 will be moved to position 0. int moveclassup(int index) The class specified by the class index will be moved up into the array of layers. Returns MS_SUCCESS or MS_FAILURE. ex layer->moveclassup(1) will have the effect of moving class 1 up to position 0, and the class at position 0 will be moved to position 1. int open() Open the layer for use with getShape(). Returns MS_SUCCESS/MS_FAILURE. shapeobj nextShape() Called after msWhichShapes has been called to actually retrieve shapes within a given area. Returns a shape object or NULL on error. .. code-block:: php $map = ms_newmapobj("d:/msapps/gmap-ms40/htdocs/gmap75.map"); $layer = $map->getLayerByName('road'); $status = $layer->open(); $status = $layer->whichShapes($map->extent); while ($shape = $layer->nextShape()) { echo $shape->index ."
\n"; } $layer->close(); int queryByAttributes(string qitem, string qstring, int mode) Query layer for shapes that intersect current map extents. qitem is the item (attribute) on which the query is performed, and qstring is the expression to match. The query is performed on all the shapes that are part of a :ref:`CLASS` that contains a :ref:`TEMPLATE