/utils/svgTemplates

The svgTemplates utility provides methods for loading and parsing SVG templates.

The utility method is called if the an svg_templates object is defined in either the locale or layer configuration.

Templates may be defined as local files, remote URLs, or data:image SVG strings.

It is recommended to use url encoding instead of base64 encoding for SVG data:image strings.

Methods

(async, inner) fetchSvgTemplate(src) → {Promise.<(string|undefined)>}

Fetches the src and returns the response text if the response is ok and the text can be parsed as an svg document. Failed fetch requests, error responses, and non svg documents [eg. an html 404 page] will be logged as warning and return undefined.

Parameters:
NameTypeDescription
srcstring

The svg template src.

Returns:
Type: 
Promise.<(string|undefined)>

(async, inner) svg_templates(templates) → {Promise.<void>}

The method parses the templates object param. Templates which are not yet available as mapp.utils.svgSymbols.templates{} will fetched and stored for use in feature style methods.

The svgTemplates method will resolve once all templates have been parsed and loaded.

Parameters:
NameTypeDescription
templatesobject

An object with svg_template properties to load.

Returns:
Type: 
Promise.<void>