Hi,
there was the post from Adrian 06-09-2010 Adding a Draggable Point in Map. And there was the sample from Yale of using EditInteractiveOverlay.
EditInteractiveOverlay editInteractiveOverlay = new EditInteractiveOverlay();
ValueStyle valueStyle = new ValueStyle();
PointShape pointShape;
private void TestForm_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.CurrentExtent = new RectangleShape(-97.7591, 30.3126, -97.7317, 30.2964);
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));
//Displays the World Map Kit as a background.
ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay();
winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);
//EditInteractiveOverlay used because it already have the logic for dragging.
//EditInteractiveOverlay editInteractiveOverlay = new EditInteractiveOverlay();
//Sets the property IsActive for DragControlPointsLayer to false so that the control point (as four arrows) is not visible.
editInteractiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
editInteractiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//Sets the property IsActive for all the Styles of EditShapesLayer because we are using a ValueStyle instead.
editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive = false;
editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive = false;
//ValueStyle used for displaying the feature according to the value of the column "Type" for displaying with a bus or car icon.
//ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "Type";
PointStyle carPointStyle = new PointStyle(new GeoImage(@"..\..\Data\car_normal.png"));
carPointStyle.PointType = PointType.Bitmap;
PointStyle busPointStyle = new PointStyle(new GeoImage(@"..\..\Data\bus_normal.png"));
busPointStyle.PointType = PointType.Bitmap;
valueStyle.ValueItems.Add(new ValueItem("Car", carPointStyle));
valueStyle.ValueItems.Add(new ValueItem("Bus", busPointStyle));
editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
editInteractiveOverlay.EditShapesLayer.Open();
editInteractiveOverlay.EditShapesLayer.Columns.Add(new FeatureSourceColumn("Type"));
editInteractiveOverlay.EditShapesLayer.Close();
Feature carFeature = new Feature(new PointShape(-97.7507, 30.3092));
carFeature.ColumnValues["Type"] = "Car";
Feature busFeature = new Feature(new PointShape(-97.7428, 30.3053));
busFeature.ColumnValues["Type"] = "Bus";
editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add("Car", carFeature);
editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add("Bus", busFeature);
//Sets the properties of EditInteractiveOverlay to have the appropriate behavior.
//Make sure CanDrag is set to true.
editInteractiveOverlay.CanAddVertex = false;
editInteractiveOverlay.CanDrag = true;
editInteractiveOverlay.CanRemoveVertex = false;
editInteractiveOverlay.CanResize = false;
editInteractiveOverlay.CanRotate = false;
editInteractiveOverlay.CalculateAllControlPoints();
winformsMap1.EditOverlay = editInteractiveOverlay;
winformsMap1.Refresh();
winformsMap1.DoubleClick += new EventHandler(winformsMap1_DoubleClick);
}
void winformsMap1_DoubleClick(object sender, EventArgs e)
{
Feature carFeature = new Feature(new PointShape(pointShape.X, pointShape.Y));
carFeature.ColumnValues["Type"] = "Car";
editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add(DateTime.Now.Ticks.ToString(), carFeature);
winformsMap1.Refresh(winformsMap1.EditOverlay);
}
private void winformsMap1_MouseMove(object sender, MouseEventArgs e)
{
//Displays the X and Y in screen coordinates.
statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y;
//Gets the PointShape in world coordinates from screen coordinates.
pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height);
//Displays world coordinates.
statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(pointShape.X, 4) + " Y:" + Math.Round(pointShape.Y, 4);
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
I have question that disturbs me for an year :) . How can I rotate Car and Bus Images?
winformsMap1.EditOverlay.EditShapeLayer.Open();
winformsMap1.EditOverlay.EditShapeLayer.EditTools.BeginTransaction()
winformsMap1.EditOverlay.EditShapeLayer.EditTools.Rotate(feature.Id, new PointShape(0,0),45);
winformsMap1.EditOverlay.EditShapeLayer.EditTools.Update(feature);
winformsMap1.EditOverlay.EditShapeLayer.EditTools.CommitTransaction();
I try code above, But there is no result. Help, please. Thank you.