ThinkGeo.com    |     Documentation    |     Premium Support

Full zoom-in level not working properly

I recently switched from the WPF map control to the winforms. I noticed that I am not able to zoom in all the way in the winforms version, even though the code is exactly the same.

Below is the main function:

private void UserControl1_Load(object sender, System.EventArgs e)
{
    string mainShapeFilePath = @"../../AppData/Merge_Countries.shp";
    winformsMap1.MapUnit = GeographyUnit.Meter;

    ShapeFileFeatureLayer.BuildIndexFile(mainShapeFilePath, BuildIndexMode.DoNotRebuild);
    ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(mainShapeFilePath);

    AreaStyle areaStyle = new AreaStyle();
    areaStyle.FillSolidBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214));
    areaStyle.OutlinePen = new GeoPen(GeoColor.FromArgb(255, 118, 138, 69), 1);
    areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;
    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;
    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
    worldLayer.Name = "World Layer";

    worldOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
    worldOverlay.Layers.Add("World Layer", worldLayer);

    winformsMap1.Overlays.Add("World Overlay", worldOverlay);

    winformsMap1.Refresh();
}

Attached is the shapefile I’m using:
testShapefile.zip (2.5 MB)

Please change the first line in the function to whatever filepath you extract the shapefile to.

Not sure what’s different between the wpf and winform versions that could cause this.

Here’s a pic of how far I’m able to zoom in. On the WPF version using the same shapefile, I can zoom in 17 more times.

Hi Dan,

I think the problem is you set the incorrect map unit.

I tried to switch the code to: winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

And it works well now.

Regards,

Ethan

Yup that did it. Thanks! Is that because the shapefile is in decimaldegree? How can I tell what units a shapefile is in?

Hi Dan,

I find that is because when I get the bouding box I found it’s not looks like meter, and then when I tested it I found it works well under decimal degree.

In fact you can only know what’s unit it is from its projection, and you can know the projection information from the data provider.

Regards,

Ethan