Gmap.net有没有信息框点击事件?谁研究过
测试了下,点击触发这个GmapTooltip信息框事件,有一个OnMouseClick事件,贴代码供大家看下
protected override void OnMouseClick(MouseEventArgs e)
{
foreach (GMapToolTip m in o.ToolTips)
{
if (m.IsVisible && m.IsHitTestVisible)
{
#region -- check --
bool isContain = m.LocalArea.Contains(e.X, e.Y);
bool isSpace = m.LocalAreaInControlSpace.Contains(e.X, e.Y);
if ((MobileMode && m.LocalArea.Contains(e.X, e.Y)) || (!MobileMode && m.LocalAreaInControlSpace.Contains(e.X, e.Y)))
{
if (OnToolTipClick != null)
{
OnToolTipClick(m, e);
}
break;
}
#endregion
}
}
红色的代码表示判断鼠标是否停留在地图所创建的矩形区域内,如果在,才会触发OnToolTipClick(m, e)这个事件.
大家踊跃讨论啊,分不够加
要自定义事件
--------------------ToolTip Close button------------------------------------------------ CloseRectangle = new System.Drawing.Rectangle(x + width - 1, y - height - 14, 12, 12); Pen closePen = new Pen(Color.FromArgb(140, Color.Red)); closePen.Alignment = PenAlignment.Center; g.DrawEllipse(closePen, CloseRectangle); TooltipFormat.Alignment = StringAlignment.Near; Brush closeBackground = Brushes.DarkRed; g.FillRectangle(closeBackground, CloseRectangle); StringFormat closeFormat = new StringFormat(); closeFormat.Alignment = StringAlignment.Center; Brush closeFontBrush = Brushes.White; g.DrawString("X", TooltipFont, closeFontBrush, CloseRectangle, closeFormat); -------------------------End---------------------------------------------- And added condition in the OnMouseClik Event in GMapControl class else if(m.CloseLocalArea.Contains(e.X, e.Y) && m.TooltipMode == MarkerTooltipMode.Always) { b = true; m.TooltipMode = MarkerTooltipMode.Never; Invalidate(false); break; }
大神,我真的没看你懂你写的这个,它里面不是有GmapToolTip这个类吗?不能再它里面添加吗?就像marker一样,只是这个信息框不是直接在overlay上,很郁闷