{"action":"opened","issue":{"url":"https://api.github.com/repos/tombatossals/angular-openlayers-directive/issues/150","labels_url":"https://api.github.com/repos/tombatossals/angular-openlayers-directive/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/tombatossals/angular-openlayers-directive/issues/150/comments","events_url":"https://api.github.com/repos/tombatossals/angular-openlayers-directive/issues/150/events","html_url":"https://github.com/tombatossals/angular-openlayers-directive/issues/150","id":96759279,"number":150,"title":"Events on vector layers trigger for every layer rather than every layer under the target pixel","user":{"login":"nblu","id":5627559,"avatar_url":"https://avatars.githubusercontent.com/u/5627559?v=3","gravatar_id":"","url":"https://api.github.com/users/nblu","html_url":"https://github.com/nblu","followers_url":"https://api.github.com/users/nblu/followers","following_url":"https://api.github.com/users/nblu/following{/other_user}","gists_url":"https://api.github.com/users/nblu/gists{/gist_id}","starred_url":"https://api.github.com/users/nblu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nblu/subscriptions","organizations_url":"https://api.github.com/users/nblu/orgs","repos_url":"https://api.github.com/users/nblu/repos","events_url":"https://api.github.com/users/nblu/events{/privacy}","received_events_url":"https://api.github.com/users/nblu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-23T08:18:57Z","updated_at":"2015-07-23T08:18:57Z","closed_at":null,"body":"If you try to add multiple vector layers the current implementation of setVectorLayerEvents causes the event to trigger for every layer which is visible rather than the layers under the pixel.\r\n\r\nI've put together an example of the issue here:\r\nhttp://jsfiddle.net/2b8fz29j/\r\n\r\nThe patch I'm proposing will be to update setVectorLayerEvents to check for the layer. For example:\r\n```javascript\r\nvar feature = map.forEachFeatureAtPixel(pixel, function(feature, olLayer) {\r\n     // only return the feature if it is in this layer (based on the name)\r\n     return (olLayer.get('name') === layerName) ? feature : null;\r\n});\r\n```\r\nI've got this update on my fork of the library and I would be happy to create a pull request to get this back in the main codebase.\r\n\r\nThanks,\r\nNick"}}