Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Scenario 1:

Let's say I have something like this:

`app_obj.MapObj.map.events.register("click", app_obj.MapObj.map, self.pointToVideoSearch);`

and another Click Control

OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
        defaultHandlerOptions: {
            "single" : true,
            "double" : false,
            "pixelTolerance" : 0,
            "stopSingle" : true,
            "stopDouble" : false
        },
        initialize: function(options){
            this.handlerOptions = OpenLayers.Util.extend(
                {}, this.defaultHandlerOptions
                );
            OpenLayers.Control.prototype.initialize.apply(this, arguments);
            this.handler = new OpenLayers.Handler.Click(
                this, {
                    "click" : this.onClick,
                    "dblclick": this.onDblclick
                }, this.handlerOptions
            );
        },

        onClick: clickFunction,
        onDblclick: dblClickFunction
    });

When I click on the map, first and second control (it's activated) are fired up. Why the "clickStop" is not working and stoping other click events to be fired?

Scenario 2:

if I had event like in Scenario 1:

app_obj.MapObj.map.events.register("click", app_obj.MapObj.map, self.pointToVideoSearch);

and a DrawFeature control to draw let's say Polygon, then the first event is silenced (when I am drawing polygon), never fires up until you are not finished with drawing polygon

My question is, what is stoping first event to fire up? I need to find out that tehnic

Thanks

share|improve this question

1 Answer 1

Try with this:

controls = { 

    point:   new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Point, {
        eventListeners: {"featureadded": newPolygonAdded}
    }),

    line:    new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Path, {
        eventListeners: {"featureadded": newPolygonAdded}
    }),

    polygon: new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Polygon, {
        eventListeners: {"featureadded": newPolygonAdded}
    }),

    regular: new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.RegularPolygon, {
        eventListeners: {"featureadded": newPolygonAdded },
        handlerOptions: {sides: 5}
    }),

    modify:  new OpenLayers.Control.ModifyFeature(vectors, {
        onModificationStart: startModify,
        onModification: doModify
    })
};

for (var key in controls)
{
    map.addControl(controls[key]);
}

And add the corresponding event functions.

share|improve this answer

Your Answer

 
discard

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.