Private Sub mnuAddRectangle_Click(sender As System.Object, e As System.EventArgs) Handles mnuAddRectangle.Click Dim BLayer As InMemoryFeatureLayer = New InMemoryFeatureLayer() BLayer.Name = "BLayer" BLayer.Open() BLayer.Columns.Add(New FeatureSourceColumn("ID")) BLayer.Columns.Add(New FeatureSourceColumn("Text")) BLayer.Columns.Add(New FeatureSourceColumn("COLOR")) BLayer.Close() 'BLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(50, GeoColor.StandardColors.Green)) BLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 PlotBuildingFeatures(BLayer) '----------------Set Projection Dim centerLatLong As Vertex centerLatLong = SetProjectionForInmemoryLayer(BLayer) WinformsMap1.CenterAt(New PointShape(centerLatLong)) WinformsMap1.Refresh() End Sub Public Sub PlotBuildingFeatures(ByVal BLayer As InMemoryFeatureLayer) Dim RectangleShapeForBuildingFloor() As RectangleShape Dim BuildingID As String Dim BuildingColor As GeoColor Dim Building_Color As String Dim DisplayText As String Dim BuildingName As String Dim BuildingLatitude As Double = 0 Dim BuildingLongitude As Double = 0 Dim LineID As String = "" Dim LineName As String = "" Dim DisplayLineText As String = "" Dim SiteLatitude As Double = 0 Dim SiteLongitude As Double = 0 Dim valueStyle As ValueStyle = New ValueStyle Dim textStyle As TextStyle = New TextStyle valueStyle.ColumnName = "COLOR" Dim BuildingLayer As GroupLayer = New GroupLayer BuildingLayer.Name = "BuildingLayer" BuildingLayer.Layers.Add("bFeatureLayer", BLayer) WinformsMap1.Overlays("layerOverlay").Lock.EnterWriteLock() Try DirectCast(WinformsMap1.Overlays("layerOverlay"), LayerOverlay).Layers.Add("BuildingLayer", BuildingLayer) Finally WinformsMap1.Overlays("layerOverlay").Lock.ExitWriteLock() End Try ReDim Preserve RectangleShapeForBuildingFloor(2) 'For First Rectangle BuildingLongitude = 77.219639 BuildingLatitude = 28.633048 Dim point As PointShape = New PointShape(BuildingLongitude, BuildingLatitude) BuildingID = "B1" BuildingColor = GeoColor.StandardColors.Blue Building_Color = "B1F1" DisplayText = "B1F1" BuildingName = DisplayText Dim PointShape1 As PointShape = New PointShape(BuildingLongitude, BuildingLatitude) 'Point Located on distance (TotWidth) in East (90 degree) location from Point1 Dim PointShape2 As PointShape = DirectCast(PointShape1.CloneDeep, PointShape) PointShape2.TranslateByDegree(0.00005, 90, WinformsMap1.MapUnit, DistanceUnit.Meter) 'Point Located on distance (TotHeight) in South (180 degree) location from Point2 Dim PointShape3 As PointShape = DirectCast(PointShape2.CloneDeep, PointShape) PointShape3.TranslateByDegree(0.00005, 180, WinformsMap1.MapUnit, DistanceUnit.Meter) RectangleShapeForBuildingFloor(0) = New RectangleShape(PointShape1, PointShape3) BLayer.InternalFeatures.Add(BuildingName, New Feature(RectangleShapeForBuildingFloor(0))) Dim buildingFeature As Feature = BLayer.InternalFeatures(BuildingName) buildingFeature.ColumnValues.Add("ID", BuildingID) buildingFeature.ColumnValues.Add("Text", DisplayText) buildingFeature.ColumnValues.Add("Color", Building_Color) valueStyle.ValueItems.Add(New ValueItem(Building_Color, AreaStyles.CreateSimpleAreaStyle(BuildingColor))) textStyle = TextStyles.CreateSimpleTextStyle("Text", "Arial", 8, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green), 2, 0, -8) 'For Second Rectangle BuildingColor = GeoColor.StandardColors.Red Building_Color = "B1F2" DisplayText = "B1F2" BuildingName = DisplayText PointShape1 = PointShape2 'Point Located on distance (TotWidth) in East (90 degree) location from Point1 PointShape2 = DirectCast(PointShape1.CloneDeep, PointShape) PointShape2.TranslateByDegree(0.00005, 90, WinformsMap1.MapUnit, DistanceUnit.Meter) 'Point Located on distance (TotHeight) in South (180 degree) location from Point2 PointShape3 = DirectCast(PointShape2.CloneDeep, PointShape) PointShape3.TranslateByDegree(0.00005, 180, WinformsMap1.MapUnit, DistanceUnit.Meter) RectangleShapeForBuildingFloor(1) = New RectangleShape(PointShape1, PointShape3) BLayer.InternalFeatures.Add(BuildingName, New Feature(RectangleShapeForBuildingFloor(1))) buildingFeature = BLayer.InternalFeatures(BuildingName) buildingFeature.ColumnValues.Add("ID", BuildingID) buildingFeature.ColumnValues.Add("Text", DisplayText) buildingFeature.ColumnValues.Add("Color", Building_Color) valueStyle.ValueItems.Add(New ValueItem(Building_Color, AreaStyles.CreateSimpleAreaStyle(BuildingColor))) textStyle = TextStyles.CreateSimpleTextStyle("Text", "Arial", 8, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green), 2, 0, -8) BLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle) BLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle) BLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 End Sub Public Function SetProjectionForInmemoryLayer(ByVal layer As InMemoryFeatureLayer) As Vertex Dim boundingBox As RectangleShape = Nothing Process.GetCurrentProcess().ProcessorAffinity = CType(1, System.IntPtr) layer.FeatureSource.Projection = Nothing If layer.HasBoundingBox Then If Not layer.IsOpen Then layer.Open() End If If boundingBox Is Nothing Then boundingBox = layer.GetBoundingBox() Else boundingBox.ExpandToInclude(layer.GetBoundingBox()) End If layer.Close() End If Dim boxArea As String = boundingBox.ToString Dim bArea() As String = Split(boxArea, ",") Dim xLatCor As Double Dim yLongCor As Double If CDbl(bArea(0)) <> 0 Then xLatCor = CDbl(bArea(0)) If xLatCor < 0 Then xLatCor = CDbl(bArea(2)) End If Else xLatCor = CDbl(bArea(2)) End If If CDbl(bArea(1)) <> 0 Then yLongCor = CDbl(bArea(1)) If yLongCor < 0 Then yLongCor = CDbl(bArea(3)) End If Else yLongCor = CDbl(bArea(3)) End If Dim decimalDegreevalue As Vertex If Math.Abs(xLatCor) > -180 And Math.Abs(xLatCor) < 180 Then 'This is decimal degree map If G_GoogleLayerSelected = True Then Dim proj4 As ManagedProj4Projection = New ManagedProj4Projection() 'proj4.InternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString() layer.FeatureSource.Projection = proj4 proj4.Open() decimalDegreevalue = proj4.ConvertToExternalProjection(CDbl(bArea(0)), CDbl(bArea(3))) proj4.Close() Else decimalDegreevalue = New Vertex(CDbl(bArea(0)), CDbl(bArea(3))) End If Else 'This is meter map Dim proj4 As ManagedProj4Projection = New ManagedProj4Projection proj4.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(32643) proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326) layer.FeatureSource.Projection = proj4 proj4.Open() decimalDegreevalue = proj4.ConvertToInternalProjection(CDbl(bArea(0)), CDbl(bArea(3))) proj4.Close() End If layer.DrawingQuality = DrawingQuality.CanvasSettings Return decimalDegreevalue End Function