all files / src/components/map-controls/polygon/ polygon.directive.ts

34.38% Statements 11/32
0% Branches 0/2
22.22% Functions 2/9
34.38% Lines 11/32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                                                                     
"use strict";
var polygon_controller_1 = require("./polygon.controller");
var PolygonTool = (function () {
    function PolygonTool($timeout, $window, olData, ol) {
        this.$timeout = $timeout;
        this.$window = $window;
        this.olData = olData;
        this.ol = ol;
        this.restrict = 'E';
        this.require = '^openlayers';
        this.template = "<os-button ng-if=\"!ctrl.noView\" variation=\"outline\" colour=\"primary\" ng-click=\"ctrl.isActive = !ctrl.isActive\">Polygon</os-button>";
        this.scope = {};
        this.bindToController = {
            featureLayer: '=osFeatureLayer',
            isActive: '=osIsActive',
            noView: '=osNoView'
        };
        this.controllerAs = 'ctrl';
        this.controller = polygon_controller_1.PolygonToolController;
        PolygonTool.prototype.link = function (scope, iElement, iAttrs, olCtrl) {
            scope.$watch('ctrl.isActive', function (isActive) {
                if (isActive !== scope.ctrl.isToolActive()) {
                    scope.ctrl.toggle();
                }
            });
            function PolygonTool_OL() {
                ol.control.Control.call(this, {
                    element: iElement[0]
                });
            }
            olData.getMap().then(function (map) {
                ol.inherits(PolygonTool_OL, ol.control.Control);
                map.addControl(new PolygonTool_OL());
            });
        };
    }
    PolygonTool.prototype.BasicControl = function (element) {
        return ol.control.Control.call(this, {
            element: element
        });
    };
    ;
    PolygonTool.Factory = function () {
        var directive = function ($timeout, $window, olData, ol) {
            return new PolygonTool($timeout, $window, olData, ol);
        };
        directive['$inject'] = ['$timeout', '$window', 'olData', 'ol'];
        return directive;
    };
    return PolygonTool;
}());
exports.PolygonTool = PolygonTool;