Hi,
I'm trying to reproject a roads shapefile on top of the world map kit but I'm having some problems getting the shapefile to display. First let me give you a little background on the shapefile and method I'm using:
The shapefile I'm using has been downloaded from a Pinellas County in Florida. The native projection of the shapefile is NAD27 Florida West State Plane. The specific file I'm using is the Roads shapefile. You can download this file for yourself at:
gis.pinellascounty.org/gisData/gisDataSets.aspx
Since I knew what the projection of the shapefile was, the next step I did was go to SpatialReference.org and find the Proj4 Projection string for this projection so I could reproject it to match the World Map Kit in code. Below is the information page I found on SpatialRefrence.org that matched the projection I was looking for.
spatialreference.org/ref/epsg/26759/
Ok, at this point I thought everything was great so I started to modify the DisplayASimpleMap sample in the HowDoISamples to see if it would work. To my expectation the map zoomed into exactly where I was expecting (the county in Florida) which made me think my projection logic worked great. However to my suprise the roads didn't display on the map. After looking at the code over and over again to make sure I didn't have a coding error dealing with my styles, I commented out the projection code and the roads displayed fine. This was a big suprise as I didn't think that projecting a shapefile would have any impact on the display of the styles. Is this a bug in the control? I'm using the latest Desktop 4.0 public release (not daily build).
Below is the code that I'm using so you can try it out for yourself:
Private Sub DisplayMap_Load(ByVal sender As Object, ByVal e As EventArgs)
winformsMap1.MapUnit = GeographyUnit.DecimalDegree
winformsMap1.BackgroundOverlay.BackgroundBrush = New GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)
Dim worldMapKitDesktopOverlay As WorldMapKitWmsDesktopOverlay = New WorldMapKitWmsDesktopOverlay()
winformsMap1.Overlays.Add(worldMapKitDesktopOverlay)
Dim roadOverlay As New LayerOverlay()
Dim roadShapeFile As New ShapeFileFeatureLayer("C:\Temp\Roads\ROADS.shp")
Dim proj As New Proj4Projection()
proj.InternalProjectionParametersString = "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192 +no_defs"
proj.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326)
roadShapeFile.FeatureSource.Projection = proj
roadShapeFile.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Red, 2, True)
roadShapeFile.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
roadOverlay.Layers.Add(roadShapeFile)
winformsMap1.Overlays.Add(roadOverlay)
roadShapeFile.Open()
'winformsMap1.CurrentExtent = New RectangleShape(-139.2, 92.4, 120.9, -93.2)
winformsMap1.CurrentExtent = roadShapeFile.FeatureSource.GetBoundingBox()
winformsMap1.Refresh()
End Sub
Any help would be appreciated.
Thanks!