Quantcast
Viewing all articles
Browse latest Browse all 2341

New Post: Having trouble with Labels and Tooltips not displaying

I think I'm missing something. I can't get Labels as tooltips to display. My application has a polygon layer and a point layer. I would like the tooltips to appear for the polygon layer. I'm running with 4.9.3 and have used the ToolTip.cs example as the basis of my code.

In the constructor I have:
            axMap1.MouseMoveEvent += axMap1_MouseMoveEvent;  // change MapEvents to axMap1
            axMap1.CursorMode = tkCursorMode.cmNone;
            axMap1.SendMouseMove = true;
            axMap1.Redraw();

            _mDrawingHandle = axMap1.NewDrawing(tkDrawReferenceList.dlScreenReferencedList);
            Labels labels = axMap1.get_DrawingLabels( _mDrawingHandle );
            axMap1.set_DrawingLabelsVisible(_mDrawingHandle, true);
            labels.FrameVisible = true;
            labels.FrameType = tkLabelFrameType.lfRectangle;
            labels.Visible = true;
And here is my MouseMove callback:
        private void axMap1_MouseMoveEvent(object sender, AxMapWinGIS._DMapEvents_MouseMoveEvent e)
        {
            if (_lyPolygon < 0) return;
            Labels labels = axMap1.get_DrawingLabels(_mDrawingHandle);
            labels.Clear();

            Shapefile sf = axMap1.get_Shapefile(_lyPolygon);
            if (sf != null)
            {
                double projX = 0.0;
                double projY = 0.0;
                axMap1.PixelToProj(e.x, e.y, ref projX, ref projY);

                object result = null;
                Extents ext = new Extents();
                ext.SetBounds(projX, projY, 0.0, projX, projY, 0.0);
                if (sf.SelectShapes(ext, 0.0, SelectMode.INTERSECTION, ref result))
                {
                    int[] shapes = result as int[];
                    if (shapes==null)  return;
                    if (shapes.Length == 1)
                    {
                        Shape shape = sf.get_Shape(shapes[0]);

                        string s = ValidateKey(shape.Key);
                        labels.AddLabel(s, e.x + 80, e.y, 0.0, -1);
                    }
                }
            }

            axMap1.Redraw2(tkRedrawType.RedrawSkipDataLayers);
        }
Using the debugger I can confirm that axMap1_MouseMoveEvent is being called, and SelectShapes() correctly returns true when the mouse hits a polygon. Also the value in s is correct.

Can anyone see what I'm missing?

Viewing all articles
Browse latest Browse all 2341

Trending Articles