From 0205bb948dddf9228d237814974ce48175c66a8b Mon Sep 17 00:00:00 2001 From: martijnlentink Date: Thu, 17 Nov 2016 14:45:37 +0100 Subject: [PATCH] Support SVG image markers I tried setting a SVG as marker image. This works great in both Chrome and Firefox, but for Edge and IE the width and height of the image tag was always 0. With this fix the correct dimensions of the image tag can be retrieved. --- src/jvectormap.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/jvectormap.js b/src/jvectormap.js index b44897c8..8fcba2ea 100644 --- a/src/jvectormap.js +++ b/src/jvectormap.js @@ -97,12 +97,18 @@ var jvm = { whenImageLoaded: function(url){ var deferred = new jvm.$.Deferred(), - img = jvm.$(''); + img = jvm.$(''); img.error(function(){ deferred.reject(); }).load(function(){ - deferred.resolve(img); + // If the client is using IE width of IMG can not + // be retrieved when src is an SVG, so we need to + // add the element to the body for a short while + if (img[0].width === 0 && img[0].height === 0) + img.appendTo(document.body); + deferred.resolve(img); + img.detach(); }); img.attr('src', url); @@ -182,4 +188,4 @@ if (!Array.prototype.indexOf) { } return -1; }; -} \ No newline at end of file +}