Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coltonbrugger master #389

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"openlayers"
],
"main": [
"dist/angular-openlayers-directive.min.js"
"dist/angular-openlayers-directive.js"
],
"dependencies": {
"angular": "1.4.9",
Expand All @@ -17,8 +17,8 @@
},
"devDependencies": {
"jquery": "*",
"angular-route": "1.4.9",
"angular-mocks": "1.4.9",
"angular-route": "1.6.6",
"angular-mocks": "1.6.6",
"js-polyfills": "^0.1.20"
},
"ignore": [
Expand Down
8 changes: 4 additions & 4 deletions src/directives/center.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular.module('openlayers-directive').directive('olCenter', function($log, $loc
if (attrs.olCenter.search('-') !== -1) {
$log.error('[AngularJS - Openlayers] The "center" variable can\'t use ' +
'a "-" on his key name: "' + attrs.center + '".');
setCenter(view, defaults.view.projection, defaults.center, map);
setCenter(view, defaults.view.projection, defaults.center);
return;
}

Expand Down Expand Up @@ -53,7 +53,7 @@ angular.module('openlayers-directive').directive('olCenter', function($log, $loc
center.zoom = 1;
}

setCenter(view, defaults.view.projection, center, map);
setCenter(view, defaults.view.projection, center);
view.setZoom(center.zoom);

var centerUrlHash;
Expand Down Expand Up @@ -134,13 +134,13 @@ angular.module('openlayers-directive').directive('olCenter', function($log, $loc
var actualCenter =
ol.proj.transform(viewCenter, defaults.view.projection, center.projection);
if (!(actualCenter[1] === center.lat && actualCenter[0] === center.lon)) {
setCenter(view, defaults.view.projection, center, map);
setCenter(view, defaults.view.projection, center);
}
}
}

if (view.getZoom() !== center.zoom) {
setZoom(view, center.zoom, map);
setZoom(view, center.zoom);
}
});

Expand Down
10 changes: 6 additions & 4 deletions src/directives/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
var olLayer;

scope.$on('$destroy', function() {
if (!isDefined(olLayer)) {
return;
}

if (scope.properties.group) {
removeLayerFromGroup(layerCollection, olLayer, scope.properties.group);
} else {
Expand Down Expand Up @@ -59,19 +63,17 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
return;
}

scope.$watch('properties', function(properties, oldProperties) {
scope.$watchCollection('properties', function(properties, oldProperties) {
if (!isDefined(properties.source) || !isDefined(properties.source.type)) {
return;
}

if (!isDefined(properties.visible)) {
properties.visible = true;
return;
}

if (!isDefined(properties.opacity)) {
properties.opacity = 1;
return;
}

var style;
Expand Down Expand Up @@ -225,7 +227,7 @@ angular.module('openlayers-directive').directive('olLayer', function($log, $q, o
}
}
}
}, true);
});
});
}
};
Expand Down
20 changes: 4 additions & 16 deletions src/services/olHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,29 +863,17 @@ angular.module('openlayers-directive').factory('olHelpers', function($q, $log, $
return false;
},

setCenter: function(view, projection, newCenter, map) {

if (map && view.getCenter()) {
view.animate({
duration: 150,
center: view.getCenter()
});
}
setCenter: function(view, projection, newCenter) {
var coord = [newCenter.lon, newCenter.lat];

if (newCenter.projection === projection) {
view.setCenter([newCenter.lon, newCenter.lat]);
view.setCenter(coord);
} else {
var coord = [newCenter.lon, newCenter.lat];
view.setCenter(ol.proj.transform(coord, newCenter.projection, projection));
}
},

setZoom: function(view, zoom, map) {
view.animate({
duration: 150,
resolution: map.getView().getResolution(),
zoom: zoom
});
setZoom: function(view, zoom) {
view.setZoom(zoom);
},

Expand Down
4 changes: 2 additions & 2 deletions test/unit/controlsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe('Directive: openlayers controls', function() {
var scope;

var containsInstance = function(controls, instance) {
for (var i in controls.array_) {
if (controls.array_[i] instanceof instance) {
for (var i in controls.getArray()) {
if (controls.getArray()[i] instanceof instance) {
return true;
}
}
Expand Down