MapScript Objects

For a complete MapScript object, variable, and method guide see the latest on the MapServer documentation web site page or Sean Gillies' reference guide (http://zcologia.com/mapserver).

Class diagrams are also available from these web sites:

Classes within the map file can be accessed as objects in MapScript. In fact, there are more objects to handle than you normally see, because MapServer does a lot of the work with them behind the scenes. The main part of a MapScript application is the map object (mapObj ). The mapObj can have many layer objects (layerObj ) as well as legend (legendObj ), scale bar (scalebarObj ), and reference map (referenceMapObj) objects. Figure 14-1 shows a diagram of how these objects are hierarchically structured.

The main object is the mapObj. You can add a layerObj, classObj , and styleObj to the mapObj. Other objects should never be explicitly created, such as webObj , scalebarObj, legendObj, and colorObj . These are already part of the mapObj, and constructing new objects for them will fail. If you get segmentation faults from MapScript, this may be the cause.

All the attributes of objects that you normally see in the map file are available for manipulation through MapScript.

Using the MapScript API is best understood by walking through some simple examples.

Get Web Mapping Illustrated now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.