Source
* @param {boolean} incremental Update method. If set to true, items are added to the existing set of map objects.
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* SVGMap class.
*
* Implements vector map rendering functionality.
*/
function SVGMap(options) {
var container,
layers;
this.layers = {};
this.options = options;
this.elements = {};
this.shapes = {};
this.links = {};
this.background = null;
this.container = null;
this.imageUrl = 'imgstore.php?iconid=';
this.imageCache = new ImageCache();
this.canvas = new SVGCanvas(options.canvas, true);
if (typeof this.options.show_timestamp === 'undefined') {
this.options.show_timestamp = true;
}
this.rendered_promise = Promise.resolve();
this.can_select_element = this.options.can_select_element || false;
this.selected_element_id = options.selected_element_id || '';
this.EVENT_ELEMENT_SELECT = 'element.select';
// Extra group for font styles.
container = this.canvas.add('g', {
class: 'map-container',
'font-family': SVGMap.FONTS[9],
'font-size': '10px'
});
var layers_to_add = [
// Background.
{
type: 'g',
attributes: {
class: 'map-background',
fill: '#' + options.theme.backgroundcolor
}
},
// Grid.
{
type: 'g',
attributes: {
class: 'map-grid',
stroke: '#' + options.theme.gridcolor,
fill: '#' + options.theme.gridcolor,
'stroke-width': '1',
'stroke-dasharray': '4,4',
'shape-rendering': 'crispEdges'
}
},
// Custom shapes.
{
type: 'g',
attributes: {
class: 'map-shapes'
}
},
// Hovered/selected indicators of elements.
{
type: 'g',
attributes: {
class: 'map-selections'
}
},
// Highlights of elements.
{
type: 'g',
attributes: {
class: 'map-highlights'
}