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

Adding Event Listeners for vector layers #5

Open
apaleja opened this issue Nov 14, 2013 · 2 comments
Open

Adding Event Listeners for vector layers #5

apaleja opened this issue Nov 14, 2013 · 2 comments
Labels

Comments

@apaleja
Copy link

apaleja commented Nov 14, 2013

Hi Matt,

I am glad to find AzimuthJS for openlayers integration. I am new to AngularJS, So I am facing some difficulty in implementation. I would like to add listeners to vector layer but I am not able to find any example for same.

how can I achieve it?

Thanks
Anand

@mpriour
Copy link
Owner

mpriour commented Nov 15, 2013

You're right the one example that would give you an idea of how to do this is overly dense with no explanation. I should address this (#6)

However, to answer your question you should simply be able to add a event-listeners attribute to the layer directive. Though I haven't tried it yet. I'm certain that a globally available function would work, I'm not sure about a function within a controller, like is possible with the map directive.

myLyrFunction(evt){
   var lyr = evt.object;
   lyr.style = ({ default: { color: '#0088ff' } });
   lyr.redraw();
}
<az-layer lyr-type="geojson"
  lyr-url="examples/data/airports.json" projection="EPSG:4326"
  event-listeners="{loadend: myLyrFunction}">
</az-layer>

@mpriour
Copy link
Owner

mpriour commented Nov 15, 2013

Nope!

There are 2 problems.

  1. The options are assumed to be protocol options for geojson layers in ol-map directives. an event-listeners attribute is applied to the wrong place. However, this should work for tile and wms layers.
  2. The function has to be in the scope available to the layer when the directive attributes are parsed. I'm not sure yet, exactly where that would be. I would think a scoped controller would do the trick, but I honestly don't know without doing some more testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants