Thanks for the help Nick. It works, but my code is in a loop, so I cannot zoom in every time and I rotate the map every time depending on which direction the train is heading. It seems that the CurrentExtent gets most of the time centered at the point but it does not get centered in the middle of the winformsMap. The point to which i want to center spirals around on the map until it does not display on the map anymore. The point represents a train and each time i get new coordinates, i remove and re-display the train layer.
See the attachment for some screen shots
Here is some of my code:
layerZone = New MapSuite.Core.ShapeFileFeatureLayer(fileName, ShapeFileReadWriteMode.ReadOnly) layerZone.Name = ZONE_LAYER TextStyle.TextColumnName = "ZONE_ID" TextStyle.Font = New GeoFont("Arial", 9) TextStyle.TextSolidBrush = New GeoSolidBrush(GeoColor.SimpleColors.Black) TextStyle.LabelAllPolygonParts = True layerZone.ZoomLevelSet.ZoomLevel04.DefaultTextStyle = TextStyle layerZone.ZoomLevelSet.ZoomLevel04.DefaultAreaStyle = New MapSuite.Core.AreaStyle(New MapSuite.Core.GeoPen(GeoColor.SimpleColors.Black, 2)) Dim transColor As New GeoSolidBrush(GeoColor.FromArgb(80, GeoColor.SimpleColors.PastelGreen)) 'make transparent layerZone.ZoomLevelSet.ZoomLevel04.DefaultAreaStyle.FillSolidBrush = transColor layerZone.ZoomLevelSet.ZoomLevel04.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 layerZone.FeatureSource.Projection = rotationProjection winformsMap1.StaticOverlay.Layers.Add(ZONE_LAYER, layerZone) 'get the area around the layer Dim tempLayer As ShapeFileFeatureLayer = DirectCast(winformsMap1.StaticOverlay.Layers(ZONE_LAYER), ShapeFileFeatureLayer) tempLayer.Open() extentLayer = tempLayer.GetBoundingBox If extentLayer.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers) > extent.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers) Then extent = extentLayer End If tempLayer.Close() winformsMap1.CurrentExtent = extent 'do this code repeatedly: 'setup the train layer as a point trainPoint = New MapSuite.Core.PointShape(vertexCollectionTrain.Item(0).X, vertexCollectionTrain.Item(0).Y) Feature = New MapSuite.Core.Feature(trainPoint, trainDictionary) trainLayer.InternalFeatures.Clear() trainLayer.Name = TRAIN_LAYER trainLayer.ZoomLevelSet.ZoomLevel04.DefaultPointStyle.PointType = PointType.Symbol trainLayer.ZoomLevelSet.ZoomLevel04.DefaultPointStyle = New PointStyle(PointSymbolType.Circle, New GeoSolidBrush(GeoColor.StandardColors.Red), 8) trainLayer.ZoomLevelSet.ZoomLevel04.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 trainLayer.InternalFeatures.Add(TRAIN_LAYER, Feature) trainLayer.FeatureSource.Projection = rotationProjection winformsMap1.StaticOverlay.Layers.Add(TRAIN_LAYER, trainLayer) 'center the train on the map winformsMap1.CenterAt(Feature) 'winformsMap1.ZoomIntoCenter(10, feature) 'winformsMap1.ZoomOutToCenter(10, feature) 'rotate the map back to North rotationProjection.Angle = -lastAngle winformsMap1.CurrentExtent = rotationProjection.GetUpdatedExtent(winformsMap1.CurrentExtent) lastAngle = 0 'rotation of the map - heading of the train rotationProjection.Angle = angle winformsMap1.CurrentExtent = rotationProjection.GetUpdatedExtent(winformsMap1.CurrentExtent) lastAngle = angle
518-Rotate_and_center2.docx (149 KB)