How to display tool tip like Google maps tool tip with close button

Aug 31, 2009 at 12:46 PM

Hi,

Thank you for providing such a great tool for displaying the locations.

I am looking for displaying the tool tip like Google maps tool tip with close button and i should be able to display multiple lines. And i would like to write the my own events on clicking the tool tip.

Please help me in integrating the tooltip in GMapMarker class.

Regards

Satish

 

Coordinator
Aug 31, 2009 at 2:10 PM

..well with wpf verson it is easy, but in .net2 it's not so trivial, any ideas?

Aug 31, 2009 at 2:28 PM

Thank you for your reply.

I havent work on wpf. Here also we can display, if the GMapMarker is like windows control. We just can assing the tool tip to the windows control.

Coordinator
Aug 31, 2009 at 5:25 PM

..for now tooltips are renderd directly on the map, but i think youcan use 

 

MainMap.OnMarkerEnter += new MarkerEnter(MainMap_OnMarkerEnter);

And there get markers local position, and display in that place any window/tooltip you want ;}

 

Coordinator
Aug 31, 2009 at 5:40 PM

something like that:

      void MainMap_OnMarkerEnter(GMapMarker item)
      {
         GMap.NET.Point p = MainMap.FromLatLngToLocal(item.Position);
         p.Offset(10, -100);

         ToolTip t = new ToolTip();
         t.IsBalloon = true;
         t.InitialDelay = 1000;
         t.Show(item.ToolTipText, MainMap, p.X, p.Y, 1000);          
      }  

Sep 1, 2009 at 7:07 AM

This is working very well, thank you for your support.

I am tryig to add the close button to the tool tip and display constantly.

Coordinator
Sep 1, 2009 at 7:09 AM

great! ;}

Sep 9, 2009 at 4:44 AM

Most likely you will have to create your own actual window class for showing tooltips in a Show() method to get built in close-[X] button functionality.  Another option would be to do your own painting of  the contents of your tooltip and track a hot-point for the drawn close-X so it acts like a window without all the overhead of a window (but some low level nitty gritty grapics stuff to do the drawing).

You might also search for an open source .NET tooltip class that is closer to what you want.

Sep 23, 2009 at 1:09 PM

Hey

I found the solution, i just drawing Rectangle in the right top corner and finding the click event on the rectangle click.

This is the code i have added in the DrawToolTip method in GMapOverlay class for displaying close button in the tooltip.

--------------------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;
                        }

Oct 16, 2009 at 6:53 AM

I have modified code for displaying tooltip like google maps, please let me know what is the procedure for uploading patch or let me know your email id, i will send you the changes.

It could be good to integrate in main code.

Coordinator
Oct 16, 2009 at 7:31 AM

just go to patch page and upload, there is link on top of front page ;}