Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple layers in OpenLayers: three vector layers, one google map layer, and a marker layer. I registered feature selected event to all three vector layers (which works fine, but btw is that a good practice to register events one by one?). When I registered the click event for marker layer, it doesn't respond.

var marker = new OpenLayers.Marker(position, icon);'click', marker, function(e){
    // Do something...

I wondered if it was caused by the problem of layer order. I tried setting ZIndex for layers, but it didn't work.

share|improve this question

There is no problem in registering events one by one. The problem is the amount of events registered. As more events more time to process them.

You must check what stuff is turned on map. Several controls that can be attached to the map maybe stopping the click event.

You can put the layer as the last layer on map, so it should be the highest.

If you do not want to register each layer event you can use the OpenLayers.Control.SelectFeature that can monitor several layers together.

  map.addControl(  new OpenLayers.Control.SelectFeature( [ vector1, vector2, markers ], { autoActivate: true } ) );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.