문제

I found in an example for OpenLayers this code to register a listener on OpenLayers.Control.SelectFeature

var report = function(e) {
     OpenLayers.Console.log(e.type, e.feature.id);
};

var highlightCtrl = new OpenLayers.Control.SelectFeature(vectors, {
    hover: true,
    highlightOnly: true,
    renderIntent: "temporary",
    eventListeners: {
            beforefeaturehighlighted: report,
            featurehighlighted: report,
            featureunhighlighted: report
    }
});

Now I'm wondering what exactly e is. What type is e and what other attributes besides type and feature doese e have? Where can I find the documentation for this?

도움이 되었습니까?

해결책

you can find other attributes of e by using IE to debug

다른 팁

In your example, the 'report' method is called a "callback method", which gets triggered when the event occurs. If you look at the SelectFeature control highlight method, you'll see that "beforefeaturehighlighted" gets triggered first. Take a look at the arguments of the method:

var cont = this.events.triggerEvent("beforefeaturehighlighted", {
    feature : feature
});

First one is the name of the event, second one is the parameters to send to the callback method. So, if you inspect your 'e' variable, as Begisen suggested, you'll see that e.feature is available.

That's what your e variable is.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top