ThinkGeo.com    |     Documentation    |     Premium Support

worldExtent exception in map suite core application

Hi,

 I got a issue in extent.

Whenever loading my application i didn’t get any exception in Extent. But next time I am changing the extent then I am getting this error.
“ArgumentNullException was unhandled”
“The parameter you supplied may not be null.Parameter name: worldExtent”

I got this exception in this code.

wfMap.FindFeatureLayer(“CircleLayer”).Open();
wfMap.CurrentExtent = ExtentHelper.GetDrawingExtent(wfMap.FindFeatureLayer(“CircleLayer”).GetBoundingBox(), wfMap.Width, wfMap.Height);
wfMap.FindFeatureLayer(“CircleLayer”).Close();

Help me to fix this issue

Note : I set proper reference of map suite core dlls.

Thanks & Regards,
Riyaz

Hi Riyaz,

It looks because the wfMap.Width get “NaN”, please use the ActualWidth instead of it, the code as below works well.

 private void WpfMap_Loaded(object sender, RoutedEventArgs e)
    {
        ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
        layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
        layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        LayerOverlay overlay = new LayerOverlay();
        overlay.Layers.Add("CircleLayer", layer);
        Map1.Overlays.Add(overlay);
        Map1.Refresh();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        Map1.FindFeatureLayer("CircleLayer").Open();
        Map1.CurrentExtent = ExtentHelper.GetDrawingExtent(Map1.FindFeatureLayer("CircleLayer").GetBoundingBox(), (float)Map1.ActualWidth, (float)Map1.ActualHeight);
        Map1.FindFeatureLayer("CircleLayer").Close();
        Map1.Refresh();
    }

Regards,

Don