Hello, I have some code that seemed to work prior to the upgrade to V12 involving MapView.
I am attempting to add an Overlay like this:
FirstMap = new MapView();
FirstMap.Overlays?.Add(new LayerOverlay()); // Crash here
I am getting a NullReferenceException everytime I try to .add to this list, I crash out with this exception:
Is there something else I need to do now before adding to the Overlays list?
Thanks,
Matt
Frank4
August 20, 2020, 7:13pm
2
Matt,
If you use the wpf mapview programmatically. You need add the map the the wpf container.
FirstMap = new MapView();
mainGrid.Children.Add(FirstMap); // Add the map to the wpf container. MainGrid is a wpf grid
FirstMap.Loaded += FirstMap_Loaded;
After map loaded you could add your overlays.
private void FirstMap_Loaded(object sender, RoutedEventArgs e)
{
FirstMap.MapUnit = GeographyUnit.Meter;
FirstMap.CurrentExtent = new RectangleShape(-10000000, 10000000, 10000000, -10000000); ;
FirstMap.Overlays?.Add(new LayerOverlay());
}
Thanks
Frank