diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-15 19:06:52 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-15 19:06:52 +1300 |
commit | f44d7cb38903508bbeb59d916ac84a0cc50d530b (patch) | |
tree | e5c6bff81c7a600341ed677a94f1a0fe729725b4 /web/app/DeviceImages.js | |
parent | 80d9fbb49758db4bab8b3750894a945c0af7fd7f (diff) | |
parent | fcd47ae26b362891514d58a02377d7fbf696b961 (diff) | |
download | etbsa-traccar-web-f44d7cb38903508bbeb59d916ac84a0cc50d530b.tar.gz etbsa-traccar-web-f44d7cb38903508bbeb59d916ac84a0cc50d530b.tar.bz2 etbsa-traccar-web-f44d7cb38903508bbeb59d916ac84a0cc50d530b.zip |
Merge pull request #316 from Abyss777/fix_icon_blinking
Remove marker style recreation on marker rotate and color change
Diffstat (limited to 'web/app/DeviceImages.js')
-rw-r--r-- | web/app/DeviceImages.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/web/app/DeviceImages.js b/web/app/DeviceImages.js index 96f0098..d976a2b 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; } }); |