Skip to content

Commit

Permalink
finished first events propagation and example
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Nov 12, 2014
1 parent 99708a7 commit 1b38edc
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 13 deletions.
23 changes: 20 additions & 3 deletions dist/angular-openlayers-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,26 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct
var setEvent = function(map, eventType, scope) {
if (eventType === "pointermove") {
map.on('pointermove', function(e) {
scope.$emit('openlayers.map.' + eventType, e);
var pixel = [e.originalEvent.offsetX, e.originalEvent.offsetY];
var coord = map.getCoordinateFromPixel(pixel);

scope.$emit('openlayers.map.' + eventType, {
lat: coord[1],
lon: coord[0],
projection: map.getView().getProjection().getCode()
});
});
} else if (eventType === 'singleclick') {
map.on('singleclick', function(e) {
var pixel = [e.originalEvent.offsetX, e.originalEvent.offsetY];
var coord = map.getCoordinateFromPixel(pixel);

console.log('hola');
scope.$emit('openlayers.map.' + eventType, {
lat: coord[1],
lon: coord[0],
projection: map.getView().getProjection().getCode()
});
});
}
};
Expand Down Expand Up @@ -1039,11 +1058,9 @@ angular.module('openlayers-directive').factory('olHelpers', ["$q", "$log", funct
for (var i in events.map) {
var event = events.map[i];
setEvent(map, event, scope);
console.log(event);
}
}


if (isDefined(layers)) {
if (isDefined(events.layers) && angular.isArray(events.layers.vector)) {
angular.forEach(events.layers.vector, function(eventType) {
Expand Down
Loading

0 comments on commit 1b38edc

Please sign in to comment.