(function () { "use strict"; angular.module("enrMapModule") .directive("enrDistrict", [function () { function link(scope, element, attr) { scope.$watch("index", function (idx) { if (idx != null && angular.element("#path" + idx)) { var pathElement = angular.element("#path" + idx)[0]; var bbox = pathElement.getBBox(); var centreX = bbox.x + bbox.width / 2; var centreY = bbox.y + bbox.height / 2; if (element) { element.attr("x", centreX); element.attr("y", centreY); } } }); scope.$watch("zoom", function (idx) { if (element != null && element != undefined) { var pathElement = angular.element("#" + element[0].id.replace("txt", "path"))[0]; var bbox = pathElement.getBBox(); var centreX = bbox.x + bbox.width / 2; var centreY = bbox.y + bbox.height / 2; if (element) { element.attr("x", centreX); element.attr("y", centreY); } } }); } return { link: link, scope: { index: "=", zoom:"=" }, restrict: "A" }; }]) }());