Skip to content

Commit

Permalink
v1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
www committed Jan 12, 2017
2 parents 7a205ce + c3fd475 commit ce28844
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 43 deletions.
53 changes: 41 additions & 12 deletions dist/angular-openlayers-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ angular.module('openlayers-directive').directive('olView', ["$log", "$q", "olDat
};
}]);

angular.module('openlayers-directive').directive('olControl', ["$log", "$q", "olData", "olMapDefaults", "olHelpers", function($log, $q, olData, olMapDefaults, olHelpers) {

angular.module('openlayers-directive')
.directive('olControl', ["$log", "$q", "olData", "olMapDefaults", "olHelpers", function($log, $q, olData, olMapDefaults, olHelpers) {
return {
restrict: 'E',
scope: {
Expand All @@ -677,29 +677,58 @@ angular.module('openlayers-directive').directive('olControl', ["$log", "$q", "ol
var olScope = controller.getOpenlayersScope();
var olControl;
var olControlOps;
var getControlClasses = olHelpers.getControlClasses;
var controlClasses = getControlClasses();

olScope.getMap().then(function(map) {
var getControlClasses = olHelpers.getControlClasses;
var controlClasses = getControlClasses();

scope.$on('$destroy', function() {
map.removeControl(olControl);
});

if (!isDefined(scope.properties) || !isDefined(scope.properties.control)) {
if (attrs.name) {
if (isDefined(scope.properties)) {
olControlOps = scope.properties;
scope.$watch('properties', function(properties) {
if (!isDefined(properties)) {
return;
}

initCtrls(properties);
});

function initCtrls(properties) {
if (properties && properties.control) {
// the control instance is already defined,
// so simply use it and go ahead

// is there already a control, so destroy and recreate it?
if (olControl) {
map.removeControl(olControl);
}
olControl = new controlClasses[attrs.name](olControlOps);

olControl = properties.control;
map.addControl(olControl);
} else {

// the name is the key to instantiate an ol3 control
if (attrs.name) {
if (isDefined(properties)) {
olControlOps = properties;
}

// is there already a control, so destroy and recreate it?
if (olControl) {
map.removeControl(olControl);
}

olControl = new controlClasses[attrs.name](olControlOps);
map.addControl(olControl);
}
}
return;
}

olControl = scope.properties.control;
map.addControl(olControl);
initCtrls(scope.properties);

});

}
};
}]);
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-openlayers-directive.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/angular-openlayers-directive.min.no-header.js

Large diffs are not rendered by default.

53 changes: 41 additions & 12 deletions dist/angular-openlayers-directive.pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ angular.module('openlayers-directive').directive('olView', function($log, $q, ol
};
});

angular.module('openlayers-directive').directive('olControl', function($log, $q, olData, olMapDefaults, olHelpers) {

angular.module('openlayers-directive')
.directive('olControl', function($log, $q, olData, olMapDefaults, olHelpers) {
return {
restrict: 'E',
scope: {
Expand All @@ -677,29 +677,58 @@ angular.module('openlayers-directive').directive('olControl', function($log, $q,
var olScope = controller.getOpenlayersScope();
var olControl;
var olControlOps;
var getControlClasses = olHelpers.getControlClasses;
var controlClasses = getControlClasses();

olScope.getMap().then(function(map) {
var getControlClasses = olHelpers.getControlClasses;
var controlClasses = getControlClasses();

scope.$on('$destroy', function() {
map.removeControl(olControl);
});

if (!isDefined(scope.properties) || !isDefined(scope.properties.control)) {
if (attrs.name) {
if (isDefined(scope.properties)) {
olControlOps = scope.properties;
scope.$watch('properties', function(properties) {
if (!isDefined(properties)) {
return;
}

initCtrls(properties);
});

function initCtrls(properties) {
if (properties && properties.control) {
// the control instance is already defined,
// so simply use it and go ahead

// is there already a control, so destroy and recreate it?
if (olControl) {
map.removeControl(olControl);
}
olControl = new controlClasses[attrs.name](olControlOps);

olControl = properties.control;
map.addControl(olControl);
} else {

// the name is the key to instantiate an ol3 control
if (attrs.name) {
if (isDefined(properties)) {
olControlOps = properties;
}

// is there already a control, so destroy and recreate it?
if (olControl) {
map.removeControl(olControl);
}

olControl = new controlClasses[attrs.name](olControlOps);
map.addControl(olControl);
}
}
return;
}

olControl = scope.properties.control;
map.addControl(olControl);
initCtrls(scope.properties);

});

}
};
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"main": "dist/angular-openlayers-directive",
"version": "1.18.1"
"version": "1.19.0"
}
53 changes: 41 additions & 12 deletions src/directives/control.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('openlayers-directive').directive('olControl', function($log, $q, olData, olMapDefaults, olHelpers) {

angular.module('openlayers-directive')
.directive('olControl', function($log, $q, olData, olMapDefaults, olHelpers) {
return {
restrict: 'E',
scope: {
Expand All @@ -12,29 +12,58 @@ angular.module('openlayers-directive').directive('olControl', function($log, $q,
var olScope = controller.getOpenlayersScope();
var olControl;
var olControlOps;
var getControlClasses = olHelpers.getControlClasses;
var controlClasses = getControlClasses();

olScope.getMap().then(function(map) {
var getControlClasses = olHelpers.getControlClasses;
var controlClasses = getControlClasses();

scope.$on('$destroy', function() {
map.removeControl(olControl);
});

if (!isDefined(scope.properties) || !isDefined(scope.properties.control)) {
if (attrs.name) {
if (isDefined(scope.properties)) {
olControlOps = scope.properties;
scope.$watch('properties', function(properties) {
if (!isDefined(properties)) {
return;
}

initCtrls(properties);
});

function initCtrls(properties) {
if (properties && properties.control) {
// the control instance is already defined,
// so simply use it and go ahead

// is there already a control, so destroy and recreate it?
if (olControl) {
map.removeControl(olControl);
}
olControl = new controlClasses[attrs.name](olControlOps);

olControl = properties.control;
map.addControl(olControl);
} else {

// the name is the key to instantiate an ol3 control
if (attrs.name) {
if (isDefined(properties)) {
olControlOps = properties;
}

// is there already a control, so destroy and recreate it?
if (olControl) {
map.removeControl(olControl);
}

olControl = new controlClasses[attrs.name](olControlOps);
map.addControl(olControl);
}
}
return;
}

olControl = scope.properties.control;
map.addControl(olControl);
initCtrls(scope.properties);

});

}
};
});

0 comments on commit ce28844

Please sign in to comment.