Custom Marker not showing Tooltip

Topics: Windows Forms
Jul 1, 2011 at 3:37 PM
Edited Jul 1, 2011 at 3:38 PM

Hi,

I've created a Custom Marker containing an Image, this works perfectly. The problem is when i assign the tooltip, it's not working, while using the GMapMarkerGoogleRed class; everthing is fine.

 

top = new GMapOverlay(gMapControl, "top");

gMapControl.Overlays.Add(top);    

var currentMarker = new GMapCustomImageMarker(new PointLatLng(Position.Lat, Position.Long))

{

ToolTipText = ToolTipText,

ToolTipMode = MarkerTooltipMode.OnMouseOver,

MarkerImage = MarkerImage

};

top.Markers.Add(currentMarker);

I also have 2 images to show that tooltips are working doe the GMapMarkerGoogleRed class but not for my GMapCustomImageMarker class.

Regards

Ariel

Coordinator
Jul 1, 2011 at 7:11 PM

this.Size = new Size(11, 11);

Jul 1, 2011 at 8:41 PM

Thanks a lot!!

Size = new Size

(markerImage.Width, markerImage.Height);

On Marker OnRender

Ariel

Coordinator
Jul 1, 2011 at 9:02 PM

not quite, put it in constructor ;} otherwise performance will drop

Jul 1, 2011 at 9:44 PM

you're very right :D

i've inserted on image property's assign... is better

one more thing, doing this... i'm having a weird behaviour related to image size and the right position on the exact Point of the map, tooltip is centered on lat and long point reference, but image is farther of the real X,Y exact points... i'm using images from this pack:

http://mapicons.nicolasmollet.com/

how do you achieve on GMapMarkerGoogleRed class this well centered behaviour? I'm very stupid on graphics :(

and thanks again

Coordinator
Jul 1, 2011 at 9:57 PM

try adjust Offset property

Jul 2, 2011 at 1:42 AM

Ok, i manage to center the tooltip and the image's pointing corner... but the clicking/hover area where the tooltip is shown on mouse over... i cannot control it... even trying to change the Offset property :(

The image is up and the hover area is down

sorry for the these simple questions

thanks a lot

Coordinator
Jul 2, 2011 at 6:56 AM

;} just experiment

Jul 3, 2011 at 8:28 AM

Check this out, works perfectly:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using GMap.NET.WindowsForms;
using GMap.NET;

namespace YourNamespace
{
    public class GMapMarkerImage : GMap.NET.WindowsForms.GMapMarker
    {
        private Image img;

  /// <summary> /// The image to display as a marker. /// </summary> public Image MarkerImage { get { return img; } set { img = value; } } /// <summary> /// Constructor /// </summary> /// <param name="p">The position of the marker</param> public GMapMarkerImage(PointLatLng p, Image image) : base(p) { img = image; Size = img.Size; Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); } public override void OnRender(Graphics g) { g.DrawImage(img, LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height); } } }

Jul 3, 2011 at 11:47 AM

Perfect!

i made something siiiimiiilar... but this is perfect

thanks a lot guys!!

Sep 21, 2012 at 8:22 PM
sorry, but how can i use this below ?
i need to use custom image markers
thanks, Marcelo
xandolph wrote:

Check this out, works perfectly:

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using GMap.NET.WindowsForms;
using GMap.NET;

namespace YourNamespace
{
    public class GMapMarkerImage : GMap.NET.WindowsForms.GMapMarker
    {
        private Image img;

  /// <summary> /// The image to display as a marker. /// </summary> public Image MarkerImage { get { return img; } set { img = value; } } /// <summary> /// Constructor /// </summary> /// <param name="p">The position of the marker</param> public GMapMarkerImage(PointLatLng p, Image image) : base(p) { img = image; Size = img.Size; Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); } public override void OnRender(Graphics g) { g.DrawImage(img, LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height); } } }

 

 

Nov 19, 2012 at 3:13 PM

Thanks arl_garm & radioman , it helped me :-)