ThinkGeo.com    |     Documentation    |     Premium Support

Drag Image along with Label

HI


I want to drag image along with label. Need an idea or code.  I can just see drag icon.
Dim pointLayer As New EditInteractiveOverlay()
Dim Rightlabel As New EditInteractiveOverlay()
Dim Icon As New ValueStyle
 
Dim RightTextStyle As New TextStyle()
RightTextStyle.TextColumnName = "Right Label"
RightTextStyle.TextSolidBrush = New GeoSolidBrush(GeoColor.StandardColors.Black)
RightTextStyle.Font = New GeoFont("Arial", 10)
RightTextStyle.PointPlacement = PointPlacement.CenterRight
RightTextStyle.YOffsetInPixel = 0
RightTextStyle.XOffsetInPixel = 20
'Icon Properties setting
 
pointLayer.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = False     pointLayer.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20        pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = False        pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive = False        pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive = False
 
'Right Label Properties setting
 
Rightlabel.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = False        Rightlabel.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20       Rightlabel.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = False       Rightlabel.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive = False        Rightlabel.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive = False
 
'Icon
 
pointLayer.EditShapesLayer.Open()
pointLayer.EditShapesLayer.Columns.Add(New FeatureSourceColumn("Type", "string", 20))
pointLayer.EditShapesLayer.Close()
 
Icon.ColumnName = "Type"
proj.Open()
Dim pos As Vertex = proj.ConvertToExternalProjection(47.5579, 29.7032)
proj.Close()
Dim Coordinates As New Feature(New PointShape(pos.X, pos.Y))
Icon.ValueItems.Add(New ValueItem(1, New PointStyle(New GeoImage("..\..\Images\sedan.png"))))
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(Icon)
Coordinates.ColumnValues.Add("Type", 1)
pointLayer.EditShapesLayer.InternalFeatures.Add("Car", Coordinates)
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
 
'Right Label
 
Rightlabel.EditShapesLayer.Open()
Rightlabel.EditShapesLayer.Columns.Add(New FeatureSourceColumn("Right Label", "string", 20))
Rightlabel.EditShapesLayer.Close()
proj.Open()
Dim pos1 As Vertex = proj.ConvertToExternalProjection(47.5579, 29.7032)
proj.Close()
Dim RPosition As New Feature(New PointShape(pos1.X, pos1.Y))
RPosition.ColumnValues.Add("Right Label","12")
Rightlabel.EditShapesLayer.InternalFeatures.Add(1, RPosition)
Rightlabel.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = RightTextStyle
Rightlabel.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
 
 
 
Rightlabel.CanAddVertex = False
Rightlabel.CanDrag = True
Rightlabel.CanRemoveVertex = False
Rightlabel.CanResize = False
Rightlabel.CanRotate = False
Rightlabel.CalculateAllControlPoints()
winformsMap1.EditOverlay = Rightlabel
 
pointLayer.CanAddVertex = False
pointLayer.CanDrag = True
pointLayer.CanRemoveVertex = False
pointLayer.CanResize = False
pointLayer.CanRotate = False
pointLayer.CalculateAllControlPoints()
winformsMap1.EditOverlay = pointLayer
 
winformsMap1.Refresh()
 
Regards,
Zeeshan

Hi Zeeshan,
 
If we need to drag the image and text at the same time, we must set the ValueStyle and TextStyle in the same EditOverlay. The following code is for your reference.
 
Dim pointLayer As New EditInteractiveOverlay()
pointLayer.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = False
pointLayer.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = False
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive = False
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive = False

’ Add Columns
pointLayer.EditShapesLayer.Open()
pointLayer.EditShapesLayer.Columns.Add(New FeatureSourceColumn(“Type”, “string”, 20))
pointLayer.EditShapesLayer.Columns.Add(New FeatureSourceColumn(“Right Label”, “string”, 20))
pointLayer.EditShapesLayer.Close()

’ Add feature
Dim feature As New Feature(New PointShape(-97.74, 30.3))
feature.ColumnValues.Add(“Type”, “1”)
feature.ColumnValues.Add(“Right Label”, “12”)
pointLayer.EditShapesLayer.InternalFeatures.Add(“Car”, feature)

’ Add styles
Dim valueStyle As New ValueStyle()
valueStyle.ColumnName = "Type"
valueStyle.ValueItems.Add(New ValueItem(“1”, PointStyles.Capital1))
Dim rightTextStyle As New TextStyle()
rightTextStyle.TextColumnName = "Right Label"
rightTextStyle.TextSolidBrush = New GeoSolidBrush(GeoColor.StandardColors.Black)
rightTextStyle.Font = New GeoFont(“Arial”, 10)
rightTextStyle.PointPlacement = PointPlacement.CenterRight
rightTextStyle.YOffsetInPixel = 0
rightTextStyle.XOffsetInPixel = 20
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle)
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(rightTextStyle)
pointLayer.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

pointLayer.CanAddVertex = False
pointLayer.CanDrag = True
pointLayer.CanRemoveVertex = False
pointLayer.CanResize = False
pointLayer.CanRotate = False
pointLayer.CalculateAllControlPoints()
winformsMap1.EditOverlay = pointLayer

winformsMap1.Refresh()

Please let us know if you have further questions.
 
Regards,
 
Ivan

Thanks It works


Regards,


Zeeshan



Zeehan,


 I am glad this is working for you. Just a reminder that we have many samples in the Code Community that deals with the issue of dragging features. And actually, there is one that is exactely like your case Dragged PointStyle with Label wiki.thinkgeo.com/wiki/Map_Suite_De...with_Label.


Thank you.