ThinkGeo.com    |     Documentation    |     Premium Support

Mini Map + Markers

I am looking at some of the Web 3.0 tools and am wondering if these have any implementation in the desktop version or samples of how to create them in desktop version.


First one, minimap, I would like a minimap display that I can specify a certain zoom level and extents for it to stay on.  


Second are the markers.  I would really like to use  markerOverlay.DragMode option instead of putting my shapes on the editlayer, I would like my users to be able to simply drag the shapes around (no resizing/shaping necessary, just dragging).  Is this possible to recreate in desktop at all?


 


Thanks


 


Jake



Jake,


Thanks for your post! Hope my following answer can give you some hints!
 
1) About the mini map, I think you can create your own AdormentLayer for this purpose!
Please try the following code to see its effects:
code.thinkgeo.com/projects/show/minimapadornment
 
2) About the DragMode functionality.
My suggestion is setting some properties to the EditOverlay as following:

winformsMap1.EditOverlay.CanDrag = true;
winformsMap1.EditOverlay.CanAddVertex = false;
winformsMap1.EditOverlay.CanRemoveVertex = false;
winformsMap1.EditOverlay.CanReshape = false;
winformsMap1.EditOverlay.CanResize = false;
winformsMap1.EditOverlay.CanRotate = false;

 

Any more questions just let me know.
 
Thanks.
 
Yale


Yale, 
    I am currently using the EditOverlay to move the shapes, but it is pretty clunky for what we are attempting to do.  What we have are in essence markers from the Web Edition.  We would like them to be moveable just like markers are in the sample (Use Draggable Markers).  What we have now are items on a Layer that the user has to click on to move to the edit layer, then try to click on the "Move" dot to drag it to a new location, then click a button to end the move mode so we can put it back on the original layer.  The draggable markers a user can simply drag to a new location without click on them first and then clicking another button/check box to finalize the move.  Is there anything that can be used like markers for the desktop edition?

Yale,  
  
     It could be that I am just using the wrong overlay as well, are there any samples of how to use the InteractiveOverlay?  Would that allow me to simulate the markers from the Webedition?  I do not want any control points displayed on the shape, I just want users to be able to drag them around. 
  
 Jake

Jake,


Hope following code can satisfy your requirements:
 

  private void TrackAndEditShapes_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("WorldLayer", worldLayer);
            winformsMap1.Overlays.Add(staticOverlay);

            winformsMap1.EditOverlay.CanDrag = true;
            winformsMap1.EditOverlay.CanAddVertex = false;
            winformsMap1.EditOverlay.CanRemoveVertex = false;
            winformsMap1.EditOverlay.CanReshape = false;
            winformsMap1.EditOverlay.CanResize = false;
            winformsMap1.EditOverlay.CanRotate = false;

            winformsMap1.TrackOverlay.TrackMode = TrackMode.Point;

            winformsMap1.TrackOverlay.TrackEnded += new EventHandler<TrackEndedTrackInteractiveOverlayEventArgs>(TrackOverlay_TrackEnded);
            winformsMap1.EditOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Transparent, 5) ;
            winformsMap1.EditOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            winformsMap1.Refresh();
        }

        void TrackOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e)
        {
            winformsMap1.TrackOverlay.TrackMode = TrackMode.None;
            winformsMap1.EditOverlay.Lock.EnterWriteLock();
            try
            {
                foreach (Feature feature in winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures)
                {
                    winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature);
                }
                winformsMap1.EditOverlay.CalculateAllControlPoints();
            }
            finally
            {
                winformsMap1.EditOverlay.Lock.ExitWriteLock();
            }

            winformsMap1.TrackOverlay.Lock.EnterWriteLock();
            try
            {
                winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();
            }
            finally
            {
                winformsMap1.TrackOverlay.Lock.ExitWriteLock();
            }

            winformsMap1.Refresh();
        }

 

Any more questions feel free to let me know.
Thanks.
 
Yale


Yale, 
  
    I have been trying to get something to work with what you gave me.  It just isn’t working out like I want.   
  
    I need a way to get the feature from an InMemoryFeatureLayer to the EditOverlay.  At least I think that is what I need to do.  Is there a way to do this on MouseDown event?  I can’t find the WorldLocation I need to search for a feature.  The rest of the code appears to work well enough.  I can drag the shape around without the control points being shown. 
  
   If it helps, here is an example of what I am trying to do. 
  
   There are 100 locations with GPS references in a database that I display on the map.  If a user wants to update the gps reference they can drag the shape around on the map.  I place the 100 locations on the map in an InMemoryFeatureLayer.   
  
   Right now I have a button that toggles a “Move Location” mode.  If this has been pushed, when they click on the location it moves it to the EditOverlay and the user can drag it around until they psuh the button to turn the Move Location mode off.  Once the mode is turned off it commits the location back to the InMemoryFeatureLayer and updates the database.  If they click on the location with the Move Location mode off it displays the Locations name to the user. 
  
   What I want:  I want the 100 locations to be displayed on the map, I don’t really care which Overlay I need to add the to.  If a user clicks the location it should display it’s name, if they drag the shape it should move around the map and update the location information in the database when they drop the shape.  In essence I want to get rid of the “Move Location” mode button and let the user move any location at any time.  I will reference the Wed Edition Markers again as the functionality I want to mirror.

Jake,  
  
 Could you use the MapClick event instead of MouseDown event? This event args will contains all the location information you needed. 
  
  
 Let me know if you have any more questions. 
  
 Thanks. 
  
 Yale 


I am currently using the mapclick event, but that requires the user to click on the object before they are able to click and drag it around the map.  I would like to save them that first click.  How do the markers from web edition work around this?  I believe they have their own Overlay that must have its features enable the drag event?


 Jake,  
  
 Just make sure what you are attempt to do is drag a point without MapClick to select it first? Then how to make a difference with the normal Pan? Then Pan will Mouse down and drag the map to a new extent. 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale 


How does the MarkerOverlay work?  “Draggable Markers” sample from the web edition samples lets you do this.  It also works if the points are on the EditOverlay.  If the mouse cursor is over the feature, drag the feature, if it isn’t over a feature, pan the map.

Jake,


Thanks for your reporting!
 
I have to say that in order to implement this functionality, you have to wait next public release or ask our support for a temporary version(3.0.405) with a bug fixed.
 
Then you can use following code to see its effect. If use the last public release , it will not compile for the ControlPointType property in the EditInteractiveOverlay are not exposed to public.

private void Form1_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

            ShapeFileFeatureLayer austinStreet = new ShapeFileFeatureLayer(@"..\..\SampleData\Countries02.shp");
            austinStreet.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            austinStreet.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("austin", austinStreet);
            winformsMap1.Overlays.Add(staticOverlay);

            austinStreet.Open();
            winformsMap1.CurrentExtent = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
            austinStreet.Close();

    winformsMap1.EditOverlay = new CustomDragEditInteractiveOverlay();
            winformsMap1.EditOverlay.CanAddVertex = false;
            winformsMap1.EditOverlay.CanRemoveVertex = false;
            winformsMap1.EditOverlay.CanReshape = false;
            winformsMap1.EditOverlay.CanResize = false;
            winformsMap1.EditOverlay.CanRotate = false;
            winformsMap1.EditOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle();

            InMemoryFeatureLayer shapeLayer = new InMemoryFeatureLayer();
            shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Collection<Vertex> vertexes = new Collection<Vertex>();
            vertexes.Add(new Vertex(150, 150));
            vertexes.Add(new Vertex(150, 100));
            vertexes.Add(new Vertex(170, 100));
            vertexes.Add(new Vertex(150, 150));

            RingShape outRing = new RingShape(vertexes);
            PolygonShape polyGon = new PolygonShape(outRing);
            Feature polygonFeature = new Feature(polyGon);
            winformsMap1.EditOverlay.EditLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            winformsMap1.EditOverlay.EditLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            winformsMap1.EditOverlay.Lock.EnterWriteLock();

            try
            {
                winformsMap1.EditOverlay.EditLayer.InternalFeatures.Add(polygonFeature);
                winformsMap1.EditOverlay.CalculateAllControlPoints();
            }
            finally
            {
                winformsMap1.EditOverlay.Lock.ExitWriteLock();
            }

            winformsMap1.Refresh();
        }
    

    public class CustomDragEditInteractiveOverlay : EditInteractiveOverlay
    {
        public CustomDragEditInteractiveOverlay() : base() 
        { }

        protected override Feature SetSelectedControlPointCore(PointShape targetPointShape, double searchingTolerance)
        {
            foreach (var item in EditShapesLayer.InternalFeatures)
            {
                // Check if the point user click is in the EditOverlay,and select the first feature to move 
                if (item.GetShape().Contains(targetPointShape))
                {
                    ControlPointType = ControlPointType.Drag;
                    return new Feature(targetPointShape.GetWellKnownBinary(), item.Id);
                }
            }

            return new Feature();
        }
    }

 

Any more questions please feel free to let me know.
 
Thanks.
 
Yale