class Map

Constants

GROW_BBOX

Grow the width or height of the specified geo bbox to fill the map size. Default behaviour.

GROW_CANVAS

Grow the width or height of the map to accommodate the specified geo bbox.

SHRINK_BBOX

Shrink the width or height of the specified geo bounding box to fill the map size.

SHRINK_CANVAS

Shrink the width or height of the map to accommodate the specified geo bounding box.

ADJUST_BBOX_WIDTH

Adjust the width of the specified geo bounding box, leave height and map size unchanged.

ADJUST_BBOX_HEIGHT

Adjust the height of the specified geo bounding box, leave width and map size unchanged.

ADJUST_CANVAS_WIDTH

Adjust the width of the map, leave height and geo bounding box unchanged.

ADJUST_CANVAS_HEIGHT

Adjust the height of the map, leave width and geo bounding box unchanged.

RESPECT

Do nothing, leave map and geo bounding box unchanged.

Methods

__construct(int $width = 400, int $height = 400, string $srs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')

Map constructor.

loadXmlString(string $xml, bool $strict = null, string $basePath = null)

Load map XML from string.

loadXmlFile(string $file, bool $strict = null, string $basePath = null)

Load XML map file.

zoom(float $zoom)

Zoom in or out by a given factor. Positive number zooms in, negative number zooms out.

zoomAll()

Set the geographical extent of the map to the combined extents of all active layers.

pan(int $x, int $y)

Set the Map center to x,y location in the coordinates of the pixmap or map surface.

panAndZoom(int $x, int $y, float $zoom)

Set Map center to x,y location and zoom in or out.

zoomToBox(Box2D $box)

Set the geographical extent of the map to Mapnik Box2D envelope.

registerFonts(string $path)

Set path to search for fonts used in map.

string
getBasePath()

Get base path used for loading map assets.

setBasePath(string $path)

Set base path used for loading map assets.

int
getWidth()

Get canvas width.

setWidth(int $width)

Set canvas width.

int
getHeight()

Get canvas height.

setHeight(int $height)

Set canvas height.

resize(int $width, int $height)

Resize the canvas to given height and width.

string
getSrs()

Get spatial reference system.

setSrs(string $srs)

Set spatial reference system.

string
getBackgroundImage()

Get path to background image.

setBackgroundImage(string $file)

Set path to background image.

float
getBackgroundImageOpacity()

Get background image opacity. 0 is transparent, 1 is opaque.

setBackgroundImageOpacity(float $opacity)

Set background image opacity. 0 is transparent, 1 is opaque.

getMaximumExtent()

Get maximum extent of projected map.

setMaximumExtent(Box2D $box)

Set maximum extent of projected map.

resetMaximumExtent()

Reset maximum extent.

getCurrentExtent()

Get current extent of projected map.

int
getBufferSize()

Get map bounds buffer size.

setBufferSize(int $bufferSize)

Set map bounds buffer. Used by placement detector to help avoid cutting labels.

getBufferedExtent()

Get extent of map with buffer applied.

float
getScale()

Get map scale.

float
getScaleDenominator()

Get scale denominator.

int
countLayers()

Count number of map layers.

removeStyle(string $styleName)

Remove a style.

removeAll()

Remove all styles and layers.

int
getAspectFixMode()

Get aspect fix mode.

setAspectFixMode(int $aspectFixMode)

Set aspect fix mode. See Map constants for valid values.

Details

at line 82
__construct(int $width = 400, int $height = 400, string $srs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')

Map constructor.

Parameters

int $width Map canvas width
int $height Map canvas height
string $srs Spatial reference system

at line 96
loadXmlString(string $xml, bool $strict = null, string $basePath = null)

Load map XML from string.

Parameters

string $xml
bool $strict
string $basePath

See also

https://github.com/mapnik/mapnik/wiki/XMLConfigReference Mapnik XML config reference

at line 106
loadXmlFile(string $file, bool $strict = null, string $basePath = null)

Load XML map file.

Parameters

string $file Path to Mapnik XML file
bool $strict Enable or disable strict map parsing
string $basePath Path to directory with map assets

See also

https://github.com/mapnik/mapnik/wiki/XMLConfigReference Mapnik XML config reference

at line 113
zoom(float $zoom)

Zoom in or out by a given factor. Positive number zooms in, negative number zooms out.

Parameters

float $zoom Zoom factor

at line 118
zoomAll()

Set the geographical extent of the map to the combined extents of all active layers.

at line 126
pan(int $x, int $y)

Set the Map center to x,y location in the coordinates of the pixmap or map surface.

Parameters

int $x Horizontal coordinate
int $y Vertical coordinate

at line 135
panAndZoom(int $x, int $y, float $zoom)

Set Map center to x,y location and zoom in or out.

Parameters

int $x Horizontal coordinate
int $y Vertical coordinate
float $zoom Zoom factor

at line 143
zoomToBox(Box2D $box)

Set the geographical extent of the map to Mapnik Box2D envelope.

Parameters

Box2D $box Bounding box

See also

Box2D Bounding box object

at line 150
registerFonts(string $path)

Set path to search for fonts used in map.

Parameters

string $path Fonts path

at line 157
string getBasePath()

Get base path used for loading map assets.

Return Value

string Base path

at line 164
setBasePath(string $path)

Set base path used for loading map assets.

Parameters

string $path Base path

at line 171
int getWidth()

Get canvas width.

Return Value

int Map width

at line 178
setWidth(int $width)

Set canvas width.

Parameters

int $width Map width

at line 185
int getHeight()

Get canvas height.

Return Value

int Map height

at line 192
setHeight(int $height)

Set canvas height.

Parameters

int $height Map height

at line 200
resize(int $width, int $height)

Resize the canvas to given height and width.

Parameters

int $width Map width
int $height Map height

at line 208
string getSrs()

Get spatial reference system.

Return Value

string proj.4 projection

See also

http://proj4.org proj.4 documentation

at line 217
setSrs(string $srs)

Set spatial reference system.

Parameters

string $srs proj.4 projection

See also

http://proj4.org proj.4 documentation
http://spatialreference.org Spatial reference system repository

at line 224
string getBackgroundImage()

Get path to background image.

Return Value

string Image path

at line 231
setBackgroundImage(string $file)

Set path to background image.

Parameters

string $file Image path

at line 238
float getBackgroundImageOpacity()

Get background image opacity. 0 is transparent, 1 is opaque.

Return Value

float Opacity

at line 245
setBackgroundImageOpacity(float $opacity)

Set background image opacity. 0 is transparent, 1 is opaque.

Parameters

float $opacity

at line 253
Box2D getMaximumExtent()

Get maximum extent of projected map.

Return Value

Box2D Maximum extent

See also

https://github.com/mapnik/mapnik/wiki/BoundsClipping Mapnik bounds clipping documentation

at line 261
setMaximumExtent(Box2D $box)

Set maximum extent of projected map.

Parameters

Box2D $box Maximum extent

See also

https://github.com/mapnik/mapnik/wiki/BoundsClipping Mapnik bounds clipping documentation

at line 266
resetMaximumExtent()

Reset maximum extent.

at line 273
Box2D getCurrentExtent()

Get current extent of projected map.

Return Value

Box2D Current extent

at line 280
int getBufferSize()

Get map bounds buffer size.

Return Value

int Buffer pixels

at line 287
setBufferSize(int $bufferSize)

Set map bounds buffer. Used by placement detector to help avoid cutting labels.

Parameters

int $bufferSize Buffer pixels

at line 294
Box2D getBufferedExtent()

Get extent of map with buffer applied.

Return Value

Box2D Buffered extent

at line 302
float getScale()

Get map scale.

Return Value

float

See also

https://github.com/mapnik/mapnik/wiki/ScaleAndPpi Mapnik scale and scale denominators documentation

at line 310
float getScaleDenominator()

Get scale denominator.

Return Value

float

See also

https://github.com/mapnik/mapnik/wiki/ScaleAndPpi Mapnik scale and scale denominators documentation

at line 317
int countLayers()

Count number of map layers.

Return Value

int

at line 324
removeStyle(string $styleName)

Remove a style.

Parameters

string $styleName Style name

at line 329
removeAll()

Remove all styles and layers.

at line 337
int getAspectFixMode()

Get aspect fix mode.

Return Value

int

See also

https://github.com/mapnik/mapnik/wiki/Aspect-Fix-Mode Mapnik aspect fix mode documentation

at line 354
setAspectFixMode(int $aspectFixMode)

Set aspect fix mode. See Map constants for valid values.

Parameters

int $aspectFixMode

See also

https://github.com/mapnik/mapnik/wiki/Aspect-Fix-Mode Mapnik aspect fix mode documentation
Map::GROW_BBOX
Map::GROW_CANVAS
Map::SHRINK_BBOX
Map::SHRINK_CANVAS
Map::ADJUST_BBOX_WIDTH
Map::ADJUST_BBOX_HEIGHT
Map::ADJUST_CANVAS_WIDTH
Map::ADJUST_CANVAS_HEIGHT
Map::RESPECT