You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a first time user with react-map-gl, when using a map with interactiveLayerIds=[SomeLayer..id] and doing console.log(event) in the onClick EventHandler, you see the following output in console:
Now you start wondering where the crucial "features" property is and try to fix things in your code. Of course nothing will change whatever you do .Then, after copy/pasting an official example (cluster example) into my codebase and also doing console.log(), you see that its the same there too. Now you realize, that console.log() just doesnt print out the "features" property. The only way to print out this property is the following:
console.log(Object.getOwnPropertyNames(event));
Which gets you this:
So you fought an error which wasnt one in the first place and thats kind of horrible.
Proposal
Dont know a proposal. Would like to see console.log include this important property when its there. Not a JS pro so i cant even figure out why its not there in the first place. Perhaps something todo with the js prototype property?
What would have helped is a hint in the docs for the interactiveLayerIds=[SomeLayer..id] property so that developers dont search for the resulting "features" property in the event via console.log() which is a quite normal quck and dirty way to inspect stuff. After this, most likely i will start sooner firing up a debugger with a breakpoint
Appendix: thanks for this great library.
The text was updated successfully, but these errors were encountered:
Harel Mazor vor 9 Monaten
This is a getter which is calculated and cached to improve performance. It's not an actual property, it just looks like so. This is one of the reasons I hardly use getters and setters - I prefer a method called "getGeometry()" to indicate that this is not a simple property...
However, now I am confused again, because the features do not show up half-transparent when logging the event… 🤔 .
Possible solution:
Following Harels comment in Slack, maybe this should be a more explicit event.getFeatures()? Something to introduce in a minor release and then slowly deprecating the old interface in the next major release?
Good grief. This got me too for a few hours--actually until I just saw this. It doesn't help that the clusters example is actually broken (see here). I think a note in the documentation would be very welcome.
Target Use Case
As a first time user with react-map-gl, when using a map with interactiveLayerIds=[SomeLayer..id] and doing console.log(event) in the onClick EventHandler, you see the following output in console:
Now you start wondering where the crucial "features" property is and try to fix things in your code. Of course nothing will change whatever you do .Then, after copy/pasting an official example (cluster example) into my codebase and also doing console.log(), you see that its the same there too. Now you realize, that console.log() just doesnt print out the "features" property. The only way to print out this property is the following:
console.log(Object.getOwnPropertyNames(event));
Which gets you this:
So you fought an error which wasnt one in the first place and thats kind of horrible.
Proposal
Dont know a proposal. Would like to see console.log include this important property when its there. Not a JS pro so i cant even figure out why its not there in the first place. Perhaps something todo with the js prototype property?
What would have helped is a hint in the docs for the interactiveLayerIds=[SomeLayer..id] property so that developers dont search for the resulting "features" property in the event via console.log() which is a quite normal quck and dirty way to inspect stuff. After this, most likely i will start sooner firing up a debugger with a breakpoint
Appendix: thanks for this great library.
The text was updated successfully, but these errors were encountered: