Select to view content in your preferred language

How to determine spatial reference of ArcGISLocalTiledLayer

2941
3
Jump to solution
10-12-2014 08:07 AM
LukePatterson
Deactivated User

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.

0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor

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.

View solution in original post

0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor

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.

0 Kudos
LukePatterson
Deactivated User

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

DominiqueBroux
Esri Frequent Contributor

Nice workaround. Thanks for sharing it.

It's definitively a fix that is in the list for the next version.

0 Kudos