I have noticed that if I add an ArcGISLocalTileLayer from a different spatial reference than the other layers in the map, I don't get an on the fly reprojection. This is fine, but I need a way to detect the conflict. How can I determine the spatial reference of this type of layer. I see a DefaultSpatialReference property that looked promising, but it is null after the layer is initialized. The layer adds to the map without any error or indication of this issue. I need a way to detect this so that I can notify the user.
Solved! Go to Solution.
To get the errors, you have to subscribe to the MapView event 'LayerLoaded'.
In the event handler, the 'LoadError' gives you the error that happened when trying to load the layer into the view.
However, you are right that the DefaultSpatialReference of the local layer is not initialized.
We'll try to fix that in a future release.
Thansk for reporting this.
To get the errors, you have to subscribe to the MapView event 'LayerLoaded'.
In the event handler, the 'LoadError' gives you the error that happened when trying to load the layer into the view.
However, you are right that the DefaultSpatialReference of the local layer is not initialized.
We'll try to fix that in a future release.
Thansk for reporting this.
Having the DefaultSpatialReference fix would be useful! I have a need to determine the spatial reference prior to adding a layer to my map.
The error shown in the LayerLoaded event is definitely useful for notifying users of a spatial reference conflict after the layer has been added.
I did find a way to determine the spatial reference of ArcGISLocalTiledLayer prior to adding to my map. Disclaimer: This is a very ugly approach that involves a dummy map
ArcGISLocalTiledLayer tiledLayer = new ArcGISLocalTiledLayer(layerDataSource.Path);
await tiledLayer.InitializeAsync();
SpatialReference tiledSpatial;
var tempView = new MapView();
tempView.Map.Layers.Add(tiledLayer);
tempView.Visibility = Visibility.Hidden;
mapGrid.Children.Add(tempView); //add invisible map
await tempView.ZoomAsync(0);
tiledSpatial = tempView.SpatialReference;
mapGrid.Children.Remove(tempView); //remove invisible map
Nice workaround. Thanks for sharing it.
It's definitively a fix that is in the list for the next version.