Skip to content

Commit

Permalink
v1.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
www committed Apr 21, 2016
2 parents e7aa4c5 + b641bb2 commit 351d308
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 23 deletions.
28 changes: 22 additions & 6 deletions dist/angular-openlayers-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa
return {
restrict: 'E',
scope: {
properties: '=olLayerProperties'
properties: '=olLayerProperties',
onLayerCreated: '&'
},
replace: false,
require: '^openlayers',
Expand Down Expand Up @@ -367,7 +368,7 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa
}
};

olLayer = createLayer(l, projection, attrs.layerName);
olLayer = createLayer(l, projection, attrs.layerName, scope.onLayerCreated);
if (detectLayerType(l) === 'Vector') {
setVectorLayerEvents(defaults.events, map, scope, attrs.name);
}
Expand Down Expand Up @@ -395,7 +396,7 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa
var group;
var collection;
if (!isDefined(olLayer)) {
olLayer = createLayer(properties, projection);
olLayer = createLayer(properties, projection, scope.onLayerCreated);
if (isDefined(properties.group)) {
addLayerToGroup(layerCollection, olLayer, properties.group);
} else if (isDefined(properties.index)) {
Expand Down Expand Up @@ -462,7 +463,7 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa

collection.removeAt(idx);

olLayer = createLayer(properties, projection);
olLayer = createLayer(properties, projection, scope.onLayerCreated);
olLayer.set('group', group);

if (isDefined(olLayer)) {
Expand Down Expand Up @@ -1482,7 +1483,8 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
origin: source.tileGrid.origin,
resolutions: source.tileGrid.resolutions,
matrixIds: source.tileGrid.matrixIds
})
}),
style: (source.style === 'undefined') ? 'normal' : source.style
};

if (isDefined(source.url)) {
Expand Down Expand Up @@ -1994,14 +1996,21 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt

detectLayerType: detectLayerType,

createLayer: function(layer, projection, name) {
createLayer: function(layer, projection, name, onLayerCreatedFn) {
var oLayer;
var type = detectLayerType(layer);
var oSource = createSource(layer.source, projection);
if (!oSource) {
return;
}

// handle function overloading. 'name' argument may be
// our onLayerCreateFn since name is optional
if (typeof(name) === 'function' && !onLayerCreatedFn) {
onLayerCreatedFn = name;
name = undefined; // reset, otherwise it'll be used later on
}

// Manage clustering
if ((type === 'Vector') && layer.clustering) {
oSource = new ol.source.Cluster({
Expand Down Expand Up @@ -2061,6 +2070,13 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
}
}

// invoke the onSourceCreated callback
if (onLayerCreatedFn) {
onLayerCreatedFn({
oLayer: oLayer
});
}

return oLayer;
},

Expand Down
4 changes: 2 additions & 2 deletions dist/angular-openlayers-directive.min.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions dist/angular-openlayers-directive.pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
return {
restrict: 'E',
scope: {
properties: '=olLayerProperties'
properties: '=olLayerProperties',
onLayerCreated: '&'
},
replace: false,
require: '^openlayers',
Expand Down Expand Up @@ -367,7 +368,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
}
};

olLayer = createLayer(l, projection, attrs.layerName);
olLayer = createLayer(l, projection, attrs.layerName, scope.onLayerCreated);
if (detectLayerType(l) === 'Vector') {
setVectorLayerEvents(defaults.events, map, scope, attrs.name);
}
Expand Down Expand Up @@ -395,7 +396,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
var group;
var collection;
if (!isDefined(olLayer)) {
olLayer = createLayer(properties, projection);
olLayer = createLayer(properties, projection, scope.onLayerCreated);
if (isDefined(properties.group)) {
addLayerToGroup(layerCollection, olLayer, properties.group);
} else if (isDefined(properties.index)) {
Expand Down Expand Up @@ -462,7 +463,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o

collection.removeAt(idx);

olLayer = createLayer(properties, projection);
olLayer = createLayer(properties, projection, scope.onLayerCreated);
olLayer.set('group', group);

if (isDefined(olLayer)) {
Expand Down Expand Up @@ -1482,7 +1483,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
origin: source.tileGrid.origin,
resolutions: source.tileGrid.resolutions,
matrixIds: source.tileGrid.matrixIds
})
}),
style: (source.style === 'undefined') ? 'normal' : source.style
};

if (isDefined(source.url)) {
Expand Down Expand Up @@ -1994,14 +1996,21 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $

detectLayerType: detectLayerType,

createLayer: function(layer, projection, name) {
createLayer: function(layer, projection, name, onLayerCreatedFn) {
var oLayer;
var type = detectLayerType(layer);
var oSource = createSource(layer.source, projection);
if (!oSource) {
return;
}

// handle function overloading. 'name' argument may be
// our onLayerCreateFn since name is optional
if (typeof(name) === 'function' && !onLayerCreatedFn) {
onLayerCreatedFn = name;
name = undefined; // reset, otherwise it'll be used later on
}

// Manage clustering
if ((type === 'Vector') && layer.clustering) {
oSource = new ol.source.Cluster({
Expand Down Expand Up @@ -2061,6 +2070,13 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
}
}

// invoke the onSourceCreated callback
if (onLayerCreatedFn) {
onLayerCreatedFn({
oLayer: oLayer
});
}

return oLayer;
},

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.11.0"
"version": "1.12.0"
}
9 changes: 5 additions & 4 deletions src/directives/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
return {
restrict: 'E',
scope: {
properties: '=olLayerProperties'
properties: '=olLayerProperties',
onLayerCreated: '&'
},
replace: false,
require: '^openlayers',
Expand Down Expand Up @@ -49,7 +50,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
}
};

olLayer = createLayer(l, projection, attrs.layerName);
olLayer = createLayer(l, projection, attrs.layerName, scope.onLayerCreated);
if (detectLayerType(l) === 'Vector') {
setVectorLayerEvents(defaults.events, map, scope, attrs.name);
}
Expand Down Expand Up @@ -77,7 +78,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
var group;
var collection;
if (!isDefined(olLayer)) {
olLayer = createLayer(properties, projection);
olLayer = createLayer(properties, projection, scope.onLayerCreated);
if (isDefined(properties.group)) {
addLayerToGroup(layerCollection, olLayer, properties.group);
} else if (isDefined(properties.index)) {
Expand Down Expand Up @@ -144,7 +145,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o

collection.removeAt(idx);

olLayer = createLayer(properties, projection);
olLayer = createLayer(properties, projection, scope.onLayerCreated);
olLayer.set('group', group);

if (isDefined(olLayer)) {
Expand Down
19 changes: 17 additions & 2 deletions src/services/olHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
origin: source.tileGrid.origin,
resolutions: source.tileGrid.resolutions,
matrixIds: source.tileGrid.matrixIds
})
}),
style: (source.style === 'undefined') ? 'normal' : source.style
};

if (isDefined(source.url)) {
Expand Down Expand Up @@ -800,14 +801,21 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $

detectLayerType: detectLayerType,

createLayer: function(layer, projection, name) {
createLayer: function(layer, projection, name, onLayerCreatedFn) {
var oLayer;
var type = detectLayerType(layer);
var oSource = createSource(layer.source, projection);
if (!oSource) {
return;
}

// handle function overloading. 'name' argument may be
// our onLayerCreateFn since name is optional
if (typeof(name) === 'function' && !onLayerCreatedFn) {
onLayerCreatedFn = name;
name = undefined; // reset, otherwise it'll be used later on
}

// Manage clustering
if ((type === 'Vector') && layer.clustering) {
oSource = new ol.source.Cluster({
Expand Down Expand Up @@ -867,6 +875,13 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
}
}

// invoke the onSourceCreated callback
if (onLayerCreatedFn) {
onLayerCreatedFn({
oLayer: oLayer
});
}

return oLayer;
},

Expand Down

0 comments on commit 351d308

Please sign in to comment.