Hi,I'm doing the followingI've cleared the Map layers collection, set the map extent to the extent and spatialreference of my second layer. Then add both my layers. The first layer originally has a different spatialreference but now is reprojected by the Map control to match the spatialreference of my second layer.Now, my program will crash if I click "FullExtent" in the Navigation control.Looking at the code the following happens:FullExtent Button Click handler: private void ZoomFullExtent_Click(object sender, RoutedEventArgs e)
{
if (Map != null)
Map.ZoomTo(Map.Layers.GetFullExtent());
}
this calls Map.Layers.GetFullExtent() where the "error" occurs:public Envelope GetFullExtent()
{
if (base.Count == 0)
{
return null;
}
Envelope extent = null;
SpatialReference spatialReference = null;
foreach (Layer layer in this)
{
if ((layer != null) && (layer.SpatialReference != null))
{
spatialReference = layer.SpatialReference;
break;
}
}
foreach (Layer layer2 in this)
{
Envelope fullExtent = layer2.FullExtent;
if (((fullExtent != null) && SpatialReference.AreEqual(fullExtent.SpatialReference, spatialReference, true)) && (fullExtent != null))
{
extent = fullExtent.Union(extent);
}
}
return extent;
}
The following piece of code sets the extent to which the map should zoom to but uses the original spatialreference of the first layer: if ((layer != null) && (layer.SpatialReference != null))
{
spatialReference = layer.SpatialReference;
break;
}
Shouldn't this code get the spatialreference from the Map control itself (when it contains layers) spatialReference = Map.FullExtent.SpatialReference
?I'm I correct or just doing stuff the wrong way?My idea was that the Map control would do the reprojection of the basemap for me, so i don't have to create a basemap for each different spatialreference.EDIT:I forgot to mention that the Map.ZoomTo() operation will fail because the SpatialReference doesn't match the spatial reference currently used by the map, thus crashing the app.