Sorry Ben, it appears that I marked this as resolved too quickly. I'm still zooming out to the entire world map when I get the bounding boxes.
Here's my code to get the bounding box, similar to yours:
Private Function GetBoundingBox() As RectangleShape
Dim result As New RectangleShape
For Each l As ShapeFileFeatureLayer In ctlDirMap.DynamicOverlay.Layers
If l.Name <> COUNTY_LAYER_NAME Then
l.FeatureSource.Open()
Dim feats As System.Collections.ObjectModel.Collection(Of Feature) = l.FeatureSource.GetAllFeatures(New String() {"FEATID"})
l.FeatureSource.Close()
result.ExpandToInclude(feats(0).GetBoundingBox())
End If
Next
Return result
End Function
No matter if I get the bounding box of the layer or the feature it still results in the rectangle being height 206994.976 and width 175000.02814.
I think the problem may be in the code I'm using to create the shape files. I think the rectangle size of the shape file is the entire world map. Here's a shortened snipper of the code I'm using to create the shape files, adapted from something you posted for me in another post:
Dim lastUSState As String = String.Empty
Dim zipLayer As ShapeFileFeatureLayer = Nothing
Dim zipShapes As New System.Collections.ObjectModel.Collection(Of AreaBaseShape)
Dim mapShapeLayer As New InMemoryFeatureLayer
mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(150, GeoColor.SimpleColors.Gold) mapShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
mapShapeLayer.InternalFeatures.Clear()
For Each zipRow In zipRows
If zipRow.STATE <> lastUSState Then
lastUSState = zipRow.STATE
If zipLayer IsNot Nothing Then
zipLayer.Close()
zipLayer = Nothing
End If
zipLayer = New ShapeFileFeatureLayer(zipMapSourcePath & zipRow.STATE & "\" & zipRow.STATE & "zcta5cu.shp")
zipLayer.RequireIndex = False
zipLayer.Open()
End If
zipFeature = zipLayer.FeatureSource.GetFeatureById(zipRow.GIST_ID.ToString, New String() {"GIST_ID", "COUNTY", "ZCTA"})
zipFeature.ColumnValues.Add("FEATID", featureId)
zipShapes.Add(zipFeature.GetShape())
Next
Dim combinedZips As MultipolygonShape = AreaBaseShape.Union(zipShapes)
mapShapeLayer.Open()
Dim proj4 As New Proj4Projection(Proj4Projection.GetEpsgParametersString(4326), Proj4Projection.GetGoogleMapParametersString()) mapShapeLayer.FeatureSource.Projection = proj4
mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.FromArgb(255, GeoColor.SimpleColors.Black)
Dim dict As New System.Collections.Generic.Dictionary(Of String, String)
dict.Add("FEATID", featureId)
mapShapeLayer.InternalFeatures.Add(featureId, New Feature(combinedZips, dict))
mapShapeLayer.Close()
Dim dbfColumns As New Collection(Of DbfColumn)
dbfColumns.Add(New DbfColumn("FEATID", DbfColumnType.String, 6, 0))
ShapeFileFeatureSource.CreateShapeFile(ShapeFileType.Polygon, outPath & "\" & featureId & ".shp", dbfColumns)
ShapeFileFeatureLayer.BuildIndexFile(outPath & "\" & featureId & ".shp")
newShapeFile = New ShapeFileFeatureLayer(outPath & "\" & featureId & ".shp", ShapeFileReadWriteMode.ReadWrite)
newShapeFile.Open()
newShapeFile.EditTools.BeginTransaction()
Dim feature1 = New Feature(mapShapeLayer.InternalFeatures.Item(featureId).GetWellKnownText)
feature1.ColumnValues.Add("FEATID", featureId)
newShapeFile.EditTools.Add(feature1)
Dim results As TransactionResult = newShapeFile.EditTools.CommitTransaction()
newShapeFile.Close()
Somehow this creates a shape file in which the feature shows up fine but the bounding box is the size of the entire world map.
Thanks, as always, for your expert assistance.
Bob Mc.