ThinkGeo.com    |     Documentation    |     Premium Support

I have shapfiles from US Census....decimal degree vs. Mercator

Hello,


When I try to load shapfiles about US ZIP or Counties it seems that when :WorldMapKitProjection.SphericalMercator;

The shapefile doesn't show on the map  but seems to work when decimaldegree......?????      



worldMapKitDesktopOverlay.Projection =



Jean-marie,


While using WorldMapKit in projection "SphericalMercator", you should use your own logic to handle shapefiles' projection transformation. Please check the following code for your reference.


winformsMap1.MapUnit = GeographyUnit.Meter;
WorldMapKitWmsDesktopOverlay worldOverlay = new WorldMapKitWmsDesktopOverlay();
worldOverlay.Projection = WorldMapKitProjection.SphericalMercator;
winformsMap1.Overlays.Add("WMK", worldOverlay);

Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
worldLayer.FeatureSource.Projection = proj4;

LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("WorldLayer", worldLayer);
winformsMap1.Overlays.Add(staticOverlay);

proj4.Open();
winformsMap1.CurrentExtent = proj4.ConvertToExternalProjection(new RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625));
proj4.Close();
winformsMap1.Refresh();


Regards,


Ivan



Works right out of the box!!! 
  
 thanks a lot!

You are welcome!  Let us know if you have any other questions. 
  
 Thanks!