From fcd47ae26b362891514d58a02377d7fbf696b961 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 14 Nov 2016 17:41:45 +0500 Subject: Remove marker style recreation on marker rotate and color change --- web/app/DeviceImages.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'web/app/DeviceImages.js') diff --git a/web/app/DeviceImages.js b/web/app/DeviceImages.js index 96f00980..d976a2b3 100644 --- a/web/app/DeviceImages.js +++ b/web/app/DeviceImages.js @@ -62,6 +62,11 @@ Ext.define('Traccar.DeviceImages', { return svg; }, + formatSrc: function (svg) { + return 'data:image/svg+xml;charset=utf-8,' + + encodeURIComponent(new XMLSerializer().serializeToString(svg.documentElement)); + }, + getImageIcon: function (color, zoom, angle, category) { var image, svg, width, height; @@ -71,14 +76,26 @@ Ext.define('Traccar.DeviceImages', { image = new ol.style.Icon({ imgSize: [width, height], - src: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(new XMLSerializer().serializeToString(svg.documentElement)) + src: this.formatSrc(svg) }); - image.load(); image.fill = color; image.zoom = zoom; image.angle = angle; image.category = category; return image; + }, + + rotateImageIcon: function (image, angle) { + var svg = Traccar.DeviceImages.getImageSvg(image.fill, image.zoom, angle, image.category); + image.getImage().src = this.formatSrc(svg); + image.angle = angle; + }, + + changeImageColor: function (image, color, category) { + var svg = Traccar.DeviceImages.getImageSvg(color, image.zoom, image.angle, category); + image.getImage().src = this.formatSrc(svg); + image.fill = color; + image.category = category; } }); -- cgit v1.2.3