Skip to content

Commit

Permalink
Allow transformations on SVG plotted points
Browse files Browse the repository at this point in the history
  • Loading branch information
neveldo committed Jun 5, 2016
1 parent 500abe5 commit cadd617
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions js/jquery.mapael.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,11 @@
elemOptions.attrs.height = elemOptions.height;
elemOptions.attrs.x = self.plots[id].mapElem.attrs.x - (elemOptions.width - self.plots[id].mapElem.attrs.width) / 2;
elemOptions.attrs.y = self.plots[id].mapElem.attrs.y - (elemOptions.height - self.plots[id].mapElem.attrs.height) / 2;
} else { // Default : circle
} else if (elemOptions.type == "svg") {
if (elemOptions.attrs.transform !== undefined) {
elemOptions.attrs.transform = self.plots[id].mapElem.baseTransform + elemOptions.attrs.transform;
}
}else { // Default : circle
elemOptions.attrs.r = elemOptions.size / 2;
}

Expand Down Expand Up @@ -1328,14 +1332,20 @@
).attr(elemOptions.attrs)
};
} else if (elemOptions.type == "svg") {
plot = {"mapElem": self.paper.path(elemOptions.path).attr(elemOptions.attrs)};
if (elemOptions.attrs.transform === undefined) {
elemOptions.attrs.transform = "";
}

plot = {"mapElem": self.paper.path(elemOptions.path)};
plot.mapElem.originalWidth = plot.mapElem.getBBox().width;
plot.mapElem.originalHeight = plot.mapElem.getBBox().height;
plot.mapElem.transform("m" + (elemOptions.width / plot.mapElem.originalWidth) + ",0,0," + (elemOptions.height / plot.mapElem.originalHeight) + "," + (coords.x - elemOptions.width / 2) + "," + (coords.y - elemOptions.height / 2));

plot.mapElem.baseTransform = "m" + (elemOptions.width / plot.mapElem.originalWidth) + ",0,0," + (elemOptions.height / plot.mapElem.originalHeight) + "," + (coords.x - elemOptions.width / 2) + "," + (coords.y - elemOptions.height / 2);
elemOptions.attrs.transform = plot.mapElem.baseTransform + elemOptions.attrs.transform;
plot.mapElem.attr(elemOptions.attrs);
} else { // Default = circle
plot = {"mapElem": self.paper.circle(coords.x, coords.y, elemOptions.size / 2).attr(elemOptions.attrs)};
}

self.initElem(plot, elemOptions, id);
return plot;
},
Expand Down

0 comments on commit cadd617

Please sign in to comment.