ThinkGeo.com    |     Documentation    |     Premium Support

Hover dialogue display in desktop version?

I plot some points on the map and displayed lines of labels. i wish to make it interact more with users, like when you hover the mouse to a point, a dialogue box will popup to display information on that particular point like in Web Edition. Is there any way to do that?


also, when you right-click a point, a context menu comes out to let user choose action to do against that point. Is it possible?


Kevin



Kevin, 



We don’t have that features built in but you can implement yourself. For example, you can get the hovering point and popup a message box using the MouseHover event, here are some sample codes for that. 




        private ScreenPointF lastMouseMove;

        private void winformsMap1_MouseMove(object sender, MouseEventArgs e)
        {
            lastMouseMove.X = e.X;
            lastMouseMove.Y = e.Y; 
        }

        private void winformsMap1_MouseHover(object sender, EventArgs e)
        {
            PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, lastMouseMove, winformsMap1.Width, winformsMap1.Height);

            double radius = 10.0 / winformsMap1.Width * winformsMap1.CurrentExtent.Width;

            EllipseShape searchingEllipse = new EllipseShape(mouseLocation, radius, radius);

// Here let’s say all the points are in EditOverlay. Sure you can do the search in any other layers as well
            foreach(Feature feature in winformsMap1.EditOverlay.EditLayer.InternalFeatures)
            {
                BaseShape tempShape = feature.GetShape();

                if (tempShape is AreaBaseShape)
                {
                    if (tempShape.Contains(mouseLocation))
                    {
                        Popup(new Point((int)lastMouseMove.X, (int)lastMouseMove.Y), feature);
                        break;
                    }
                }
                else if (tempShape.Intersects(searchingEllipse))
                {
                    Popup(new Point((int)lastMouseMove.X, (int)lastMouseMove.Y),feature);
                    break;
                }
            }
        }

        private void Popup(Point location, Feature feature)
        {
            // display information
        }



Similarly, you can popup your own context menu by hooking up MapClick event: 




  private void winformsMap1_MapClick(object sender, MapClickEventArgs e)
        {
            if (e.MouseButton == MapMouseButton.Right)
            {
                contextMenuStrip1.Show();
            }
        }

Let us know if you have any issues. 



Thanks 



Ben 

 



Thanks Ben for your answers, but i do have some issues: 
  
 1) when i use lastMouseMove (of type ScreenPointF), the compiler has error: 
 Property or indexer ‘ThinkGeo.MapSuite.Core.ScreenPointF.X’ cannot be assigned to – it is read only 
 Property or indexer ‘ThinkGeo.MapSuite.Core.ScreenPointF.Y’ cannot be assigned to – it is read only 
  
 2) allow me a basic question, my markers are declared this way: 
 InMemoryFeatureLayer markerLayer = new InMemoryFeatureLayer(); 
 markerLayer.InternalFeatures.Add(… 
 winformsMap1.DynamicOverlay.Layers.Add(“MarkerLayer”, markerLayer); 
  
 How do i access all the features (markers) using foreach for such DynamicOverlay? like: foreach(Feature feature in winformsMap1.EditOverlay.EditLayer.InternalFeatures) 
  
 Kevin 
  
  


Here are the answers, Kevin. 



1) Please use the following statement instead. 


lastMouseMove = new ScreenPointF(e.X, e.Y);

I used this at the very beginning in my code but when I posted it, I thought using lastMouseMove.X = e.X is better. Sometimes doing more things just screws things up. :( 


2) You can code like this. 



InMemoryFeatureLayer inMemoryFeatureLayer = (InMemoryFeatureLayer)winformsMap1.DynamicOverlay.Layers["MarkerLayer"];
foreach (Feature feature in inMemoryFeatureLayer.InternalFeatures)

Just need to convert the layer to a InMemoryFeatureLayer. 



Thanks, 



Ben 



Ben, 



i was able to get the contextmenu to work correctly by adjusting the coordinates, but the hover part is not working properly. It seems that the code can't recognize when the mouse is already at the top of the markers, because it is checking if it intersects with marker in the MouseHover method. i placed the checking in the MouseMove method, and it worked perfectly. 


thanks.



 



Kevin, 
  
  I had a try and you are right, the MouseMove works perfectly. Thanks for letting me know.  
  
 Ben

What are you then doing to display a popup? I was able to successfully implement the code above to find location and have added FeatureSourceColumns to my Feature to hold the data I want to display, however, I am not finding any sort of callout method within thinkGeo. Is this functionality not built?

Levi,


Thanks for your post and welcome you to ThinkGeo Destkop Edition discussion forum.
 
We do not have a built-in popup implementation as web did, following post contains some information as well as a simple demo about it. Please take a look if you are interested.
gis.thinkgeo.com/Support/Dis...fault.aspx
 
Let me know if any more questions.
 
Thanks.
 
Yale