Hi.
I'm trying to edit projected feature but edit controls do not show on the map.
Here is the shape before edit:
Here is the shape in edit mode:
Is something missing in my code?
'this is polygon wkt in decimal degree
Private Const WKT_4326 As String = "POLYGON((-94.6860836942215 41.4901824383996,-94.6841988242231 41.4903756977292,-94.6841988242231 41.4938864748692,-94.684584365692 41.4954968589591,-94.6863407220226 41.4960443803575,-94.6881399161648 41.4963664496318,-94.6931947949342 41.4965274835704,-94.6925093876198 41.4937898505013,-94.6931519571226 41.4917284969706,-94.6927235773765 41.4913097764365,-94.6914384388365 41.491213148227,-94.6871118051931 41.4904401174281,-94.6860836942215 41.4901824383996))"
Private Sub Shell_Load(sender As Object, e As System.EventArgs) Handles Me.Load
map4326_3395.MapUnit = ThinkGeo.MapSuite.Core.GeographyUnit.Meter
btnEdit4326_3395.Enabled = False
End Sub
Private Sub btnLoad4326_3395_Click(sender As System.Object, e As System.EventArgs) Handles btnLoad4326_3395.Click
btnLoad4326_3395.Enabled = False
btnEdit4326_3395.Enabled = True
Load4326_3395()
End Sub
Private Sub btnEdit4326_3395_Click(sender As System.Object, e As System.EventArgs) Handles btnEdit4326_3395.Click
btnEdit4326_3395.Enabled = False
EditShape(map4326_3395)
End Sub
'projection function
Private Function GeodeticToMercatorProjection() As Proj4Projection
Dim proj As New Proj4Projection()
proj.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326)
proj.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3395)
Return proj
End Function
Private Sub Load4326_3395()
Dim overlay As New LayerOverlay
Dim layer As New InMemoryFeatureLayer
'NOTE: feature is in decimal degree but projection is mercator
' rendering is working properly while editing fails???
Dim f As Feature = New Feature(WKT_4326) 'create new feature from wkt
Dim extent As RectangleShape
overlay = New LayerOverlay
layer = New InMemoryFeatureLayer
layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.LightGreen)
layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.DarkGreen
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
layer.FeatureSource.Projection = GeodeticToMercatorProjection()
'apply projection to the edit layer, otherwise shape will not show on the map
map4326_3395.EditOverlay.EditShapesLayer.FeatureSource.Projection = GeodeticToMercatorProjection()
layer.InternalFeatures.Add(f)
overlay.Layers.Add(layer)
map4326_3395.Overlays.Add(overlay)
layer.Open()
extent = layer.GetBoundingBox
layer.Close()
map4326_3395.CurrentExtent = extent
map4326_3395.Refresh()
End Sub
Private Sub EditShape(map As WinformsMap)
Dim layer As InMemoryFeatureLayer = CType(CType(map.Overlays(0), LayerOverlay).Layers(0), InMemoryFeatureLayer)
Dim key As String = layer.InternalFeatures.GetKeys(0)
Dim f As Feature = layer.InternalFeatures(0)
map.TrackOverlay.TrackMode = TrackMode.None
map.EditOverlay.EditShapesLayer.InternalFeatures.Add(key, f)
map.EditOverlay.CalculateAllControlPoints()
layer.InternalFeatures.Clear()
map.Refresh(New Overlay() {map.Overlays(0), map.EditOverlay})
End Sub
001_EditOverlayDriver.zip (59.2 KB)