Hi,
Why does the marker.MouseHover method not fire?
I assign an event listener:
marker.MouseHover += markerHover;
But this does not fire? However, the MouseMove and Click events both fire for the Marker. My aim is to have a method that is executed on a hover of a marker, something similar to how marker.ToolTipText works.
Any help on why this is the case would be great.
Regards,
Sam
Marker MouseHover Problem
** It works for the Click event and MouseMoveEvent, not MouseMove.
Hi Sam,
Does that because the event stopped by some other control in the top of mark?
Could you please paste more detail code include how you add the mark to map and whether map contains other layers?
And I want to know your detail dll version.
That’s helpful for us to reproduce that.
Regards,
Don
There is no other control on-top of mark.
I add the Markers from a collection of features.
Marker marker =
new
Marker(feature.GetShape().GetCenterPoint());
marker.Image = Image.FromFile(@
"…"
);
marker.MouseMoveEvent += markerMove;
marker.ToolTipText = setMarkerText(feature);
marker.Width = 32;
marker.Height = 32;
marker.YOffset = -17;
markerOverlay.Markers.Add(marker);
Yes the map does contain other layers: Shapefile Feature Layer, Feature Layer and an InMemoryFeatureLayer.
The dll version is 8.0.0.110.
Any help on this would be great.
Regards,
Sam
Hi Sam,
Thanks for your code.
I found in fact we haven’t implemented special mouse hover event for marker object, so that event is hard to be fired(in your sample, it can be fired when you move mouse to a position in the right side of your marker.)
Here is the solution for your requirement:
1. Inherit from Marker class.
2. Create your MouseHoverEvent in your new class.
3. Pass your new markers into SimpleMarkerOverlay when you create it.
Here is some important code for implement your class:
public event EventHandler<EventArgs> MouseHoverEvent;
this.ControlAdded += new ControlEventHandler(Marker_ControlAdded);
void Marker_ControlAdded(object sender, ControlEventArgs e)
{
e.Control.MouseHover += new EventHandler(MarkerControl_MouseHover);
}
void MarkerControl_MouseHover(object sender, EventArgs e)
{
if (MouseHoverEvent != null)
{
MouseHoverEvent(this, e);
}
}
Wish it’s helpful.
Please let me know if you have any question.
Regards,
Don
Hi Don,
Thank you for that. I will try it and get back to you with the result.
Regards,
Sam.
Hi Sam,
I am waiting for your good news on it.
Any question please let us know.
Regards,
Don
Hi Don,
The solution you gave works really well. I do have a question though.
Currently, the event is fired very quickly, i.e. almost immediately. Is there any way we can alter this to happen after a similar time to the Marker’s tool-tip? So the event becomes a true hover.
Any help on this would be great.
Kind Regards,
Sam
Hi Sam,
I think maybe we cannot control this.
The MarkerControl_MouseHover is fired by system control and it looks the Mouse Hover time is a system static setting. I think we should can read it but cannot modify it in code.
For my machine, the default value looks is 20ms, I think I can only modify it via Registry Editor.
So maybe you want to Google it for more information, I am not sure whether there is any workaround about it.
Regards,
Don