ThinkGeo.com    |     Documentation    |     Premium Support

Questions on interactive overlays

I have created a custom interactive overlay, inherited from the EditInteractiveOverlay.  We insert the editor into the InteractiveOverlays collection at position 0, intending it to the frist editor to have a crack at the mouse events.


I'm running build 331.


In the MouseClickCore, we clear the internal EditShapesLayer and then search in an attached layer for a containing shape.  If found, we load that shape into the editor.     This is working fine.   My selected shape shows up, with vertices highlighted, a drag symbol, rotate symbol, etc.   The problem that I'm having is that none of the edit action is actually working.   When I click on the drag symbol, the entire map drags.   When I click on the rotate button and move it, the entire map moves.   When I click on a vertex and drag it, the vertex turns red, but the entire map moves.   When I double-click a vertex, the map zooms in.


Also, if I set CanResize, CanRotate, etc to false, I was expecting that I would NOT see their respective sizing and rotating symbols.  But they symbols are always there, no matter what.    Do I need to explicitly recalculate only the vertex control points, for instance, if I don't want resizing and rotation symbols?


I don't know where to start on resolving this.   Here is my MouseClickCore code:


 


protected override InteractiveResult MouseClickCore(InteractionArguments interactionArguments) { try { this.Lock.EnterWriteLock(); bool hadShape = (this.EditShapesLayer.InternalFeatures.Count > 0); this.EditShapesLayer.InternalFeatures.Clear(); _attachmentsLayer.FeatureSource.Projection.Open(); Collection<feature> features = _attachmentsLayer.QueryTools.GetFeaturesContaining(new PointShape(interactionArguments.WorldX, interactionArguments.WorldY), ReturningColumnsType.AllColumns); if (features.Count >= 1) { foreach (Feature f in features) { this.EditShapesLayer.InternalFeatures.Add(f); } this.CalculateAllControlPoints(); return new InteractiveResult(InteractiveOverlayDrawType.Draw, ProcessOtherOverlaysMode.DoNotProcessOtherOverlays); } else { InteractiveResult r = base.MouseClickCore(interactionArguments); if (hadShape) r.DrawThisOverlay = InteractiveOverlayDrawType.Draw; return r; } } catch (Exception ex) { logger.Error("MouseClickCore", ex); return new InteractiveResult(InteractiveOverlayDrawType.Draw, ProcessOtherOverlaysMode.DoNotProcessOtherOverlays); } finally { this.Lock.ExitWriteLock(); } } 


Also, when I clear this overlay and don't want any shape to be included, I still have the Vertex and Resize control points displayed on the screen until the next map refresh.



Never mind... the behavior is as expected.   When working with David in training last week, we had trouble with the InsertAt method for adding overlays and had change to code to "Add" for testing purposes.  Thus, my new editor was accessed only after other editors got a shot, and the extent overlay was jumping in and moving the map.  


So, I'm not sure if David got it reported, but there is an issue with the InteractiveOverlays.InsertAt method.   It won't accept a key... only an overlay.   As such, there is no option to remove the overlay by key.   We have to remove it by passing the instance, or do RemoveAt calls, which are very cumbersome.


Try this.   Create two different overlay editors.  Add them to the InteractiveOverlays collection by inserting at zero.   Then remove them, either with Remove or RemoveAt.   I think the first one removes ok, and the second will fail, with a "collection cannot be null" error.


David wrote this down last week, but I'm not sure it made it to a developer.


Update:  RemoveAt fails after adding two editors and then removint the last one added.


Thanks



Ted,


Thanks for your post!


I did not get the issue from David yet, but I think it is on the way!


I made a simple test based on what you talked about, and the result seems OK.


Following is my tests and comments are the result with (3.0.331 and latest codes), I think the result is expected.


 



MyExtentInterativeOverlay myTestOverlay1 = new MyExtentInterativeOverlay();
myTestOverlay1.Name = "TestOverlay1";

MyExtentInterativeOverlay myTestOverlay2 = new MyExtentInterativeOverlay();
myTestOverlay2.Name = "TestOverlay2";

// After this, we get 4 overlays in InterativeOverlays
winformsMap1.InteractiveOverlays.Insert(0, myTestOverlay1);

// After this, we get 5 overlays in InterativeOverlays
winformsMap1.InteractiveOverlays.Insert(0, myTestOverlay2);

//The "TestOverlay2" was removed.
winformsMap1.InteractiveOverlays.RemoveAt(0);

//The "TestOverlay1" was removed.
winformsMap1.InteractiveOverlays.RemoveAt(0);


Can you let me know which is the problem in the little tests?


Any more questions just let me know.


Thanks.


Yale



You have the idea right.   I my case, TestOverLay1 is my own class, derived from the TrackInteractiveOverlay, and TestOverlay2 is my own class derived from EditInteractiveOverlay.


And, of course, I loaded data into each of the layers. after adding them to the collection, and before removing them. 


If you still cannot reproduce it, I can try to do a small program this weekend.




 Ted, 
  
 Thanks for your post! 
  
 I still cannot recreate the problem you mentioned exactly, If you can supply the small test app that would be very grateful! I will very appreciate it! 
  
 Any more questions just let me know. 
  
 Thanks. 
  
 Yale