The Wayback Machine - https://web.archive.org/web/20210121182422/https://github.com/jbelien/MapFile-PHP-Library
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 

README.md

MapFile-PHP-Library

Latest Stable Version Total Downloads Monthly Downloads Software License

PHP Library to read/write MapServer mapfiles.

This library is based on MapServer 7.2.0 documentation (last updated on 16 June 2017).

Installation

composer require jbelien/mapfile-php-library:2.x-dev

Usage

Write MapFile (example)

$map = new \MapFile\Model\Map();

$map->name = 'my-mapfile';
$map->projection = 'EPSG:4326';

$map->scalebar = new \MapFile\Model\Scalebar();
$map->scalebar->units = 'kilometers';

$layer = new \MapFile\Model\Layer();
$layer->name = 'my-layer';
$layer->type = 'POLYGON';
$layer->status = 'ON';
$layer->data = 'my-shapefile';
$layer->projection = 'EPSG:4326';

$class = new \MapFile\Model\LayerClass();

$style = new \MapFile\Model\Style();
$style->color = [0, 0, 0];
$class->style->add($style);

$label = new \MapFile\Model\Label();
$label->text = '[label]';
$label->color = [0, 0, 0];
$label->size = 12;
$class->label->add($label);

$layer->class->add($class);

$map->layer->add($layer);

$mapfile = (new \MapFile\Writer\Map())->write($map);

Have a look at the source code to see all the available options.

Parse MapFile (example)

$map = (new \MapFile\Parser\Map())->parse('my-mapfile.map');

foreach ($map->layer as $layer) {
    echo $layer->name;
}