ThinkGeo.com    |     Documentation    |     Premium Support

Tooltips not working in SimpleMarkerOverlay

Hello,

I’ve searched the forum for how to display the tooltips as displayed in the following thread:

This may/may not be available in Desktop Winforms Edition as it is in WPF or Web Edition. I extracted the code from the link above. I have placed this code in the map_click event handler, so I think I’m adding a marker tooltip for each point I click on. Also, I’ve added all the points I want to display to an InMemoryFeatureLayer, with the same location as the marker.

Any help on displaying the tooltip would be greatly appreciated.

private void m_mapControl_MapClick(object sender, MapClickWinformsMapEventArgs e)
{

// ... stuff deleted

Marker marker = new Marker(pt.DisplayLongitude.Value, pt.Latitude_degN);
marker.ToolTipText = "Lat: " + pt.Latitude_degN + "°N Lon: " + pt.DisplayLongitude.Value + "°E";
marker.Image = Properties.Resources.security_lock_enabled16; // random image to display to determine if the marker actually displays
marker.Width = 20;
marker.Height = 20;
marker.YOffset = -17;
marker.Visible = true;
m_tooltipOverlay.Markers.Add(pt.Id.ToString(), marker);

m_mapControl.Refresh(m_tooltipOverlay);

}

Thanks,
Jamar

Hi Jamar,

The code should also works for winforms version.

Please try this sample: 8684.zip (103.2 KB)

It shows how the marker works.

Regards,

Ethan

Ethan,

Thanks! It definitely showed me what needed to change.

Hi Jamar,

I am glad to hear that’s helpful.

Regards,

Ethan