Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmishne committed Dec 20, 2015
1 parent dc87e85 commit b46b522
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 60 deletions.
2 changes: 1 addition & 1 deletion dist/angular-openlayers-directive.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
left: -8px;
top: 5px;
}


.angular-openlayers-map:-moz-full-screen {
height: 100%;
}
Expand Down
112 changes: 85 additions & 27 deletions dist/angular-openlayers-directive.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['ol'], function (ol) {
return root.angularOpenlayersDirective = factory(ol);
});
} else {
// Browser globals
root.angularOpenlayersDirective = factory(root.ol);
}
}(this, function (ol) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['ol'], function (ol) {
return root.angularOpenlayersDirective = factory(ol);
});
} else {
// Browser globals
root.angularOpenlayersDirective = factory(root.ol);
}
}(this, function (ol) {
angular.module('openlayers-directive', ['ngSanitize']).directive('openlayers', ["$log", "$q", "$compile", "olHelpers", "olMapDefaults", "olData", function($log, $q, $compile, olHelpers,
olMapDefaults, olData) {
return {
Expand Down Expand Up @@ -86,6 +86,10 @@ angular.module('openlayers-directive', ['ngSanitize']).directive('openlayers', [
view: view
});

scope.$on('$destroy', function() {
olData.resetMap(attrs.id);
});

// If no layer is defined, set the default tileLayer
if (!attrs.customLayers) {
var l = {
Expand Down Expand Up @@ -122,7 +126,7 @@ angular.module('openlayers-directive', ['ngSanitize']).directive('openlayers', [
}
};
}]);


angular.module('openlayers-directive').directive('olCenter', ["$log", "$location", "olMapDefaults", "olHelpers", function($log, $location, olMapDefaults, olHelpers) {

return {
Expand Down Expand Up @@ -306,7 +310,7 @@ angular.module('openlayers-directive').directive('olCenter', ["$log", "$location
}
};
}]);


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

return {
Expand Down Expand Up @@ -423,6 +427,14 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa
}
}

if (properties.minResolution) {
olLayer.setMinResolution(properties.minResolution);
}

if (properties.maxResolution) {
olLayer.setMaxResolution(properties.maxResolution);
}

} else {
var isNewLayer = (function(olLayer) {
// this function can be used to verify whether a new layer instance has
Expand Down Expand Up @@ -504,13 +516,27 @@ angular.module('openlayers-directive').directive('olLayer', ["$log", "$q", "olMa
olLayer.setStyle(style);
}
}

//set min resolution
if (!equals(properties.minResolution, oldProperties.minResolution) || isNewLayer(olLayer)) {
if (isDefined(properties.minResolution)) {
olLayer.setMinResolution(properties.minResolution);
}
}

//set max resolution
if (!equals(properties.maxResolution, oldProperties.maxResolution) || isNewLayer(olLayer)) {
if (isDefined(properties.maxResolution)) {
olLayer.setMaxResolution(properties.maxResolution);
}
}
}
}, true);
});
}
};
}]);


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

return {
Expand Down Expand Up @@ -568,7 +594,7 @@ angular.module('openlayers-directive').directive('olPath', ["$log", "$q", "olMap
}
};
}]);


angular.module('openlayers-directive').directive('olView', ["$log", "$q", "olData", "olMapDefaults", "olHelpers", function($log, $q, olData, olMapDefaults, olHelpers) {
return {
restrict: 'A',
Expand Down Expand Up @@ -620,7 +646,7 @@ 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) {

return {
Expand Down Expand Up @@ -661,7 +687,7 @@ angular.module('openlayers-directive').directive('olControl', ["$log", "$q", "ol
}
};
}]);


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

var getMarkerDefaults = function() {
Expand Down Expand Up @@ -1077,7 +1103,7 @@ angular.module('openlayers-directive').directive('olMarker', ["$log", "$q", "olM
}
};
}]);


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

var obtainEffectiveMapId = olHelpers.obtainEffectiveMapId;
Expand Down Expand Up @@ -1128,8 +1154,14 @@ angular.module('openlayers-directive').service('olData', ["$log", "$q", "olHelpe
return defer.promise;
};

}]);
this.resetMap = function(scopeId) {
if (angular.isDefined(maps[scopeId])) {
delete maps[scopeId];
}
};

}]);

angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$http", function($q, $log, $http) {

var isDefined = function(value) {
Expand Down Expand Up @@ -1170,6 +1202,7 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
attribution: ol.control.Attribution,
fullscreen: ol.control.FullScreen,
mouseposition: ol.control.MousePosition,
overviewmap: ol.control.OverviewMap,
rotate: ol.control.Rotate,
scaleline: ol.control.ScaleLine,
zoom: ol.control.Zoom,
Expand Down Expand Up @@ -1367,6 +1400,10 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
attributions: createAttribution(source)
};

if (source.serverType) {
wmsConfiguration.serverType = source.serverType;
}

if (source.url) {
wmsConfiguration.url = source.url;
}
Expand Down Expand Up @@ -1738,12 +1775,23 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
createView: function(view) {
var projection = createProjection(view);

return new ol.View({
var viewConfig = {
projection: projection,
maxZoom: view.maxZoom,
minZoom: view.minZoom,
extent: view.extent
});
minZoom: view.minZoom
};

if (view.center) {
viewConfig.center = view.center;
}
if (view.extent) {
viewConfig.extent = view.extent;
}
if (view.zoom) {
viewConfig.zoom = view.zoom;
}

return new ol.View(viewConfig);
},

// Determine if a reference is defined and not null
Expand Down Expand Up @@ -1909,7 +1957,7 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
if ((type === 'Vector') && layer.clustering) {
oSource = new ol.source.Cluster({
source: oSource,
distance: layer.clusteringDistance,
distance: layer.clusteringDistance
});
}

Expand All @@ -1935,6 +1983,13 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
oLayer.set('name', layer.name);
}

// set custom layer properties if given
if (isDefined(layer.customAttributes)) {
for (var key in layer.customAttributes) {
oLayer.set(key, layer.customAttributes[key]);
}
}

return oLayer;
},

Expand Down Expand Up @@ -2027,8 +2082,11 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt

insertLayer: function(layers, index, layer) {
if (layers.getLength() < index) {
// fill up with "null layers" till we get to the desired index
while (layers.getLength() < index) {
layers.push(null);
var nullLayer = new ol.layer.Image();
nullLayer.index = layers.getLength(); // add index which will be equal to the length in this case
layers.push(nullLayer);
}
layer.index = index;
layers.push(layer);
Expand Down Expand Up @@ -2059,7 +2117,7 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", "$htt
}
};
}]);


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

var base64icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAGmklEQVRYw' +
Expand Down Expand Up @@ -2204,5 +2262,5 @@ angular.module('openlayers-directive').factory('olMapDefaults', ["$q", "olHelper
}
};
}]);


}));
7 changes: 4 additions & 3 deletions dist/angular-openlayers-directive.min.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

Loading

0 comments on commit b46b522

Please sign in to comment.