Skip to content

Commit

Permalink
feature(path): Added a new ol-path tag to add polygons into the map
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Jan 18, 2015
1 parent d8b48c0 commit 77688d9
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 119 deletions.
2 changes: 1 addition & 1 deletion css/markers.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
vertical-align: middle;
}

.popup-label:before {
.popup-label.marker:before {
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
content: "";
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-openlayers-directive.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
vertical-align: middle;
}

.popup-label:before {
.popup-label.marker:before {
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
content: "";
Expand Down
120 changes: 70 additions & 50 deletions dist/angular-openlayers-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,22 @@ angular.module('openlayers-directive')

var layer = createVectorLayer();
map.addLayer(layer);
if (isDefined(attrs.coord)) {
if (isDefined(attrs.coords)) {
var proj = attrs.proj || 'EPSG:4326';
var coord = JSON.parse(attrs.coord);
var coords = JSON.parse(attrs.coords);
var data = {
type: 'Polygon',
coord: coord,
projection: proj
coords: coords,
projection: proj,
style: mapDefaults.styles.path
};
var feature = createFeature(data, viewProjection);
layer.getSource().addFeature(feature);

if (attrs.message) {
scope.message = attrs.message;
var pos = ol.proj.transform(coord, proj, viewProjection);
var label = createOverlay(element, pos);
var extent = feature.getGeometry().getExtent();
var label = createOverlay(element, extent);
map.addOverlay(label);
}
return;
Expand Down Expand Up @@ -561,52 +562,13 @@ angular.module('openlayers-directive')
.directive('olMarker', ["$log", "$q", "olMapDefaults", "olHelpers", function($log, $q, olMapDefaults, olHelpers) {

var getMarkerDefaults = function() {
var base64icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAGmklEQVRYw' +
'7VXeUyTZxjvNnfELF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evsLK10Py8SdMGfXNXATY+pPbyJR/ET6n9nIfztNtZYRV9XniQu9IA2vOVgy4ir7GC' +
'LVmmd+zjkH0eAF9Po6K61pmCXHxU5rHMYd1ftc3owjwRSVRzLjKvqZEty6cRUD7jGqiOdu5HG6MdHjN' +
'cNYGqfDm5YRzLBBCCDl/2bk8a8gdbqcfwECu62Fg/HrggAAAABJRU5ErkJggg==';
return {
projection: 'EPSG:4326',
lat: 0,
lon: 0,
coord: [],
show: true,
showOnMouseOver: false,
style: new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 1],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
opacity: 0.90,
src: base64icon
})
})
showOnMouseOver: false
};
};

Expand All @@ -620,7 +582,7 @@ angular.module('openlayers-directive')
},
require: '^openlayers',
replace: true,
template: '<div class="popup-label" ng-bind-html="message"></div>',
template: '<div class="popup-label marker" ng-bind-html="message"></div>',

link: function(scope, element, attrs, controller) {
var isDefined = olHelpers.isDefined;
Expand Down Expand Up @@ -649,6 +611,7 @@ angular.module('openlayers-directive')
data.lat = scope.lat ? scope.lat : data.lat;
data.lon = scope.lon ? scope.lon : data.lon;
data.message = attrs.message;
data.style = mapDefaults.styles.marker;

marker = createFeature(data, viewProjection);
if (!isDefined(marker)) {
Expand Down Expand Up @@ -852,6 +815,8 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct
var createStyle = function(style) {
var fill;
var stroke;
var image;

if (style.fill) {
fill = new ol.style.Fill({
color: style.fill.color
Expand All @@ -864,9 +829,15 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct
width: style.stroke.width
});
}

if (style.image) {
image = style.image;
}

return new ol.style.Style({
fill: fill,
stroke: stroke
stroke: stroke,
image: image
});
};

Expand Down Expand Up @@ -1286,7 +1257,7 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct

switch (data.type) {
case 'Polygon':
geometry = new ol.geom.Polygon(data.coord);
geometry = new ol.geom.Polygon(data.coords);
break;
default:
if (isDefined(data.coord) && data.projection === 'pixel') {
Expand All @@ -1306,7 +1277,8 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct
});

if (isDefined(data.style)) {
feature.setStyle(data.style);
var style = createStyle(data.style);
feature.setStyle(style);
}
return feature;
},
Expand Down Expand Up @@ -1345,6 +1317,37 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct
}]);

angular.module('openlayers-directive').factory('olMapDefaults', ["$q", "olHelpers", function($q, olHelpers) {
var base64icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAGmklEQVRYw' +
'7VXeUyTZxjvNnfELFuyIzOabermMZEeQC/OclkO49CpOHXOLJl/CAURuYbQi3KLgEhbrhZ1aDwmaoGq' +
'KII6odATmH/scDFbdC7LvFqOCc+e95s2VG50X/LLm/f4/Z7neY/ne18aANCmAr5E/xZf1uDOkTcGcWR' +
'6hl9247tT5U7Y6SNvWsKT63P58qbfeLJG8M5qcgTknrvvrdDbsT7Ml+tv82X6vVxJE33aRmgSyYtcWV' +
'MqX97Yv2JvW39UhRE2HuyBL+t+gK1116ly06EeWFNlAmHxlQE0OMiV6mQCScusKRlhS3QLeVJdl1+23' +
'h5dY4FNB3thrbYboqptEFlphTC1hSpJnbRvxP4NWgsE5Jyz86QNNi/5qSUTGuFk1gu54tN9wuK2wc3o' +
'+Wc13RCmsoBwEqzGcZsxsvCSy/9wJKf7UWf1mEY8JWfewc67UUoDbDjQC+FqK4QqLVMGGR9d2wurKzq' +
'Bk3nqIT/9zLxRRjgZ9bqQgub+DdoeCC03Q8j+0QhFhBHR/eP3U/zCln7Uu+hihJ1+bBNffLIvmkyP0g' +
'pBZWYXhKussK6mBz5HT6M1Nqpcp+mBCPXosYQfrekGvrjewd59/GvKCE7TbK/04/ZV5QZYVWmDwH1mF' +
'3xa2Q3ra3DBC5vBT1oP7PTj4C0+CcL8c7C2CtejqhuCnuIQHaKHzvcRfZpnylF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ZBthUaZhUnjlYObNagV' +
'3keoeru3rU7rcuceqU1mJBxy+BWZYlNEBH+0eH4vRiB+OYybU2hnblYlTvkHinM4m54YnxSyaZYSF6R' +
'3jwgP7udKLGIX6r/lbNa9N6y5MFynjWDtrHd75ZvTYAPO/6RgF0k76mQla3FGq7dO+cH8sKn0Vo7nDl' +
'lwAhqwLPkxrHwWmHJOo+AKJ4rab5OgrM7rVu8eWb2Pu0Dh4eDgXoOfvp7Y7QeqknRmvcTBEyq9m/HQQ' +
'SCSz6LHq3z0yzsNySRfMS253wl2KyRDbcZPcfJKjZmSEOjcxyi+Y8dUOtsIEH6R2wNykdqrkYJ0RV92' +
'H0W58pkfQk7cKevsLK10Py8SdMGfXNXATY+pPbyJR/ET6n9nIfztNtZYRV9XniQu9IA2vOVgy4ir7GC' +
'LVmmd+zjkH0eAF9Po6K61pmCXHxU5rHMYd1ftc3owjwRSVRzLjKvqZEty6cRUD7jGqiOdu5HG6MdHjN' +
'cNYGqfDm5YRzLBBCCDl/2bk8a8gdbqcfwECu62Fg/HrggAAAABJRU5ErkJggg==';

var _getDefaults = function() {
return {
view: {
Expand All @@ -1363,6 +1366,23 @@ angular.module('openlayers-directive').factory('olMapDefaults', ["$q", "olHelper
centerUrlHash: false,
projection: 'EPSG:4326'
},
styles: {
path: {
stroke: {
color: 'blue',
width: 8
}
},
marker: {
image: new ol.style.Icon({
anchor: [0.5, 1],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
opacity: 0.90,
src: base64icon
})
}
},
events: {
map: [],
markers: [],
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-openlayers-directive.min.js

Large diffs are not rendered by default.

22 changes: 7 additions & 15 deletions examples/110-path-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,16 @@
<link rel="stylesheet" href="../dist/angular-openlayers-directive.css" />
<script>
var app = angular.module("demoapp", ["openlayers-directive"]);
app.controller("DemoController", [ '$scope', function($scope) {
angular.extend($scope, {
center: {
lat: -34.60,
lon: -58.38,
zoom: 10
}
});
} ]);

app.controller("DemoController", [ '$scope', function($scope) {} ]);
</script>
</head>
<body ng-controller="DemoController">
<openlayers ol-center="center" height="400px" width="100%">
<ol-path message="This is a path" coord="[[[-58.38,-34.60], [-59.38,-35.60]]]"></ol-path>
<openlayers lat="-34.60" lon="-58.38" zoom="10" height="400px" width="100%">
<ol-path message="This is a path" coords="[[[-58.38,-34.60], [-58.58,-34.60]]]"></ol-path>
<ol-path message="And this is another path" coords="[[[-58.38,-34.70], [-58.38,-34.80]]]"></ol-path>
<ol-path message="Hello there" coords="[[[-58.48,-34.40], [-58.58,-34.50]]]"></ol-path>
</openlayers>
<h1>Adding a geometry object to the map</h1>
<p>You can add a marker to the map easily with the <strong>ol-marker</strong> sub-directive.</p>
<pre ng-bind="markers | json"></pre>
<h1>Adding a path to the map</h1>
<p>You can add a path to the map easily with the <strong>ol-path</strong> sub-directive.</p>
</body>
</html>
44 changes: 3 additions & 41 deletions src/directives/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,13 @@ angular.module('openlayers-directive')
.directive('olMarker', function($log, $q, olMapDefaults, olHelpers) {

var getMarkerDefaults = function() {
var base64icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAGmklEQVRYw' +
'7VXeUyTZxjvNnfELFuyIzOabermMZEeQC/OclkO49CpOHXOLJl/CAURuYbQi3KLgEhbrhZ1aDwmaoGq' +
'KII6odATmH/scDFbdC7LvFqOCc+e95s2VG50X/LLm/f4/Z7neY/ne18aANCmAr5E/xZf1uDOkTcGcWR' +
'6hl9247tT5U7Y6SNvWsKT63P58qbfeLJG8M5qcgTknrvvrdDbsT7Ml+tv82X6vVxJE33aRmgSyYtcWV' +
'MqX97Yv2JvW39UhRE2HuyBL+t+gK1116ly06EeWFNlAmHxlQE0OMiV6mQCScusKRlhS3QLeVJdl1+23' +
'h5dY4FNB3thrbYboqptEFlphTC1hSpJnbRvxP4NWgsE5J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B1/RfMw6rY7cxcjTrneI1FrDyuzUSRm9miwEJx8E/gUmql' +
'yvHGkneiwErR21F3tNOK5Tf0yXaT+O7DgCvALTUBXdM4YhC/IawPU+2PduqMvuaR6eoxSwUk75ggqsY' +
'J7VicsnwGIkZBSXKOUww73WGXyqP+J2/b9c+gi1YAg/xpwck3gJuucNrh5JvDPvQr0WFXf0piyt8f8/' +
'WI0hV4pRxxkQZdJDfDJNOAmM0Ag8jyT6hz0WGXWuP94Yh2jcfjmXAGvHCMslRimDHYuHuDsy2QtHuIa' +
'vznhbYURq5R57KpzBBRZKPJi8eQg48h4j8SDdowifdIrEVdU+gbO6QNvRRt4ZBthUaZhUnjlYObNagV' +
'3keoeru3rU7rcuceqU1mJBxy+BWZYlNEBH+0eH4vRiB+OYybU2hnblYlTvkHinM4m54YnxSyaZYSF6R' +
'3jwgP7udKLGIX6r/lbNa9N6y5MFynjWDtrHd75ZvTYAPO/6RgF0k76mQla3FGq7dO+cH8sKn0Vo7nDl' +
'lwAhqwLPkxrHwWmHJOo+AKJ4rab5OgrM7rVu8eWb2Pu0Dh4eDgXoOfvp7Y7QeqknRmvcTBEyq9m/HQQ' +
'SCSz6LHq3z0yzsNySRfMS253wl2KyRDbcZPcfJKjZmSEOjcxyi+Y8dUOtsIEH6R2wNykdqrkYJ0RV92' +
'H0W58pkfQk7cKevsLK10Py8SdMGfXNXATY+pPbyJR/ET6n9nIfztNtZYRV9XniQu9IA2vOVgy4ir7GC' +
'LVmmd+zjkH0eAF9Po6K61pmCXHxU5rHMYd1ftc3owjwRSVRzLjKvqZEty6cRUD7jGqiOdu5HG6MdHjN' +
'cNYGqfDm5YRzLBBCCDl/2bk8a8gdbqcfwECu62Fg/HrggAAAABJRU5ErkJggg==';
return {
projection: 'EPSG:4326',
lat: 0,
lon: 0,
coord: [],
show: true,
showOnMouseOver: false,
style: new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 1],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
opacity: 0.90,
src: base64icon
})
})
showOnMouseOver: false
};
};

Expand All @@ -61,7 +22,7 @@ angular.module('openlayers-directive')
},
require: '^openlayers',
replace: true,
template: '<div class="popup-label" ng-bind-html="message"></div>',
template: '<div class="popup-label marker" ng-bind-html="message"></div>',

link: function(scope, element, attrs, controller) {
var isDefined = olHelpers.isDefined;
Expand Down Expand Up @@ -90,6 +51,7 @@ angular.module('openlayers-directive')
data.lat = scope.lat ? scope.lat : data.lat;
data.lon = scope.lon ? scope.lon : data.lon;
data.message = attrs.message;
data.style = mapDefaults.styles.marker;

marker = createFeature(data, viewProjection);
if (!isDefined(marker)) {
Expand Down
13 changes: 7 additions & 6 deletions src/directives/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ angular.module('openlayers-directive')

var layer = createVectorLayer();
map.addLayer(layer);
if (isDefined(attrs.coord)) {
if (isDefined(attrs.coords)) {
var proj = attrs.proj || 'EPSG:4326';
var coord = JSON.parse(attrs.coord);
var coords = JSON.parse(attrs.coords);
var data = {
type: 'Polygon',
coord: coord,
projection: proj
coords: coords,
projection: proj,
style: mapDefaults.styles.path
};
var feature = createFeature(data, viewProjection);
layer.getSource().addFeature(feature);

if (attrs.message) {
scope.message = attrs.message;
var pos = ol.proj.transform(coord, proj, viewProjection);
var label = createOverlay(element, pos);
var extent = feature.getGeometry().getExtent();
var label = createOverlay(element, extent);
map.addOverlay(label);
}
return;
Expand Down
Loading

0 comments on commit 77688d9

Please sign in to comment.