Skip to content

Commit 09a236d

Browse files
author
ChenGuanglin
committed
【bug】ie11中svg渲染失败
review by zhaoq
1 parent e011b47 commit 09a236d

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/openlayers/core/StyleUtils.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,26 @@ export class StyleUtils {
623623
}
624624
if (type === "POINT") {
625625
if (src) {
626-
newImage = new ol.style.Icon({
627-
src: src,
628-
scale: scale,
629-
anchor: anchor
630-
});
626+
if (/.+(\.svg$)/.test(src)) {
627+
if(!this.svgDiv) {
628+
this.svgDiv = document.createElement('div');
629+
document.body.appendChild(this.svgDiv);
630+
}
631+
this.getCanvasFromSVG(src, this.svgDiv, (canvas) => {
632+
newImage = new ol.style.Icon({
633+
img: canvas,
634+
scale: radius / canvas.width,
635+
imgSize: [canvas.width, canvas.height],
636+
anchor : [0.5, 0.5]
637+
})
638+
})
639+
} else {
640+
newImage = new ol.style.Icon({
641+
src: src,
642+
scale: scale,
643+
anchor: anchor
644+
});
645+
}
631646
} else {
632647
newImage = new ol.style.Circle({
633648
radius: radius,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy