VectorRenderer#

class VectorRenderer(**properties: Any)#

Superclasses: MapSource, Object

Implemented Interfaces: Initable

A MapSource that renders tiles from a given vector data source.

Constructors#

class VectorRenderer
classmethod new(id: str, style_json: str) VectorRenderer#

Creates a new VectorRenderer from the given JSON style.

The stylesheet should contain a list of tile sources. Tiles will be downloaded using TileDownloaders.

See the MapLibre Style Specification for details on style_json, but be aware that libshumate does not support every feature of the specification.

Parameters:
  • id – an ID for the map source

  • style_json – a vector style

Methods#

class VectorRenderer
get_global_state(key: str) VectorValue#

Gets a global state value.

If the value has not been set with set_global_state, the default defined in the style will be returned, or None if no default is defined. Note that an explicitly set null value will return a VectorValue of type null, while an undefined value will return None.

Added in version 1.6.

Parameters:

key – the state key

get_sprite_sheet() VectorSpriteSheet#

Gets the sprite sheet used to render icons and textures.

Added in version 1.1.

classmethod is_supported() bool#

Checks whether libshumate was compiled with vector tile support. Previous versions of libshumate had a build-time option to disable vector tiles, but as of 1.6 they are always enabled.

reset_global_state(key: str) None#

Resets a global state value to the default defined in the style, or to null if no default is defined.

Added in version 1.6.

Parameters:

key – the state key

set_data_source(name: str, data_source: DataSource) None#

Adds a data source to the renderer.

Currently, VectorRenderer only supports one data source and throws an error if the style does not contain exactly one data source. However, support for multiple sources may be added in the future, so this method accepts a name parameter. If the name does not match the one expected by the style, this method will have no effect.

Added in version 1.2.

Parameters:
  • name – the name of the data source

  • data_source – a DataSource

set_global_state(key: str, value: VectorValue) None#

Sets a global state value.

Global state can be accessed in the stylesheet through the “global-state” expression operator. This allows styles to provide options that can be configured without changing the style JSON.

Previously rendered tiles are not affected by changes to global state and must be re-rendered.

Added in version 1.6.

Parameters:
  • key – the state key

  • value – the state value

set_sprite_sheet(sprites: VectorSpriteSheet) None#

Sets the sprite sheet used to render icons and textures.

Added in version 1.1.

Parameters:

sprites – a VectorSpriteSheet

set_sprite_sheet_data(sprites_pixbuf: Pixbuf, sprites_json: str) bool#

Sets the sprite sheet used by the style JSON to render icons and textures.

The existing sprite_sheet property will be replaced with a new instance of VectorSpriteSheet.

Deprecated since version 1.1: Use the methods of sprite_sheet instead.

Parameters:
  • sprites_pixbuf – a Pixbuf

  • sprites_json – a JSON string

Properties#

class VectorRenderer
props.sprite_sheet: VectorSpriteSheet#

The sprite sheet used to render icons and textures.

Added in version 1.1.

props.style_json: str#

A map style, in Mapbox Style Specification format.

Note that not all features of the specification are supported.