Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

[attach-detach] MapLabel to marker while EventHandler [ENTERED-EXITED] #84

Open
oosam2 opened this issue Jun 17, 2020 · 1 comment
Open

Comments

@oosam2
Copy link

oosam2 commented Jun 17, 2020

Hi Peter-Josef Meisch :)

I can`t attachLabel() to marker while EventHandler is MARKER_ENTERED and detachLabel() to marker while EventHandler is MARKER_EXITED
Ex

mapView.addEventHandler(MarkerEvent.MARKER_ENTERED, event -> {
     event.consume();
     event.getMarker().attachLabel(new MapLabel("MARKER_ENTERED"));
});

mapView.addEventHandler(MarkerEvent.MARKER_EXITED, event -> {
     event.consume();
     event.getMarker().detachLabel();
});

I found simple css solution
-with MARKER_ENTERED I add css
display: block;
-with MARKER_EXITED I add css
display: none;

can you added to next version?


Also
sometime i get marker img highlight
Untitled

ma by this css useful
user-select: none;

thank you very much for this library
🌹🌹🌹🌹🌹🌹

@sothawo
Copy link
Owner

sothawo commented Jun 17, 2020

mapView.addEventHandler(MarkerEvent.MARKER_ENTERED, event -> {
     event.consume();
     event.getMarker().attachLabel(new MapLabel("MARKER_ENTERED"));
});

The label you create in the event handler will go out of scope as soon as the event handler is exited and the it will be garbage collected and removed. You have to create the label outside of this function and then in the handler you can attach it or detach it. You will have to set the label to unvisible after detaching it. As long as the label is attached to the marker, it will have the same visibility state.

As for the highlighted images: I have seen this now just once, but have not yet found what causes this element to be selected; I cannot reproduce it all the times

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

No branches or pull requests

2 participants