Problem with tile layer which is loaded from package

1669
5
01-26-2017 05:10 AM
MichaelStruk
New Contributor II

Hi

I encountered a problem with tile layer.

I initialized map with spatial reference and am trying to display tile map layer from a *.mpk file.

Layer and a map has the same spatial reference  WGS 84 (4326 WKID), but layer not displayed.

If i Initialize the map without defining the spatial reference, a layer is displayed.

var map = new Map(SpatialReference.Create(4326));

var layer = new ArcGISTiledLayer(new Uri(source));

map.Basemap.BaseLayers.Add(layer );

 EsriMapView.Map = map;

Does anyone encountered this problem?

Thanks for your help

0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
            MyMapView.LayerViewStateChanged += MyMapView_LayerViewStateChanged;

            MyMapView.Map = new Map(SpatialReferences.Wgs84);
            MyMapView.Map.Basemap.BaseLayers.Add(new ArcGISTiledLayer(new Uri(@"C:\layer.tpk")));
        }

        private void MyMapView_LayerViewStateChanged(object sender, LayerViewStateChangedEventArgs e)
        {
            // You can check this value and compare with e.Layer.FullExtent
            // MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry)
            if (e.LayerViewState.Status == LayerViewStatus.Active)
                MyMapView.SetViewpoint(new Viewpoint(e.Layer.FullExtent));
        }‍‍‍‍‍‍‍‍‍‍‍

When Map SpatialReference is set upfront, the MapView's viewpoint becomes the entire world's extent. This is why your layer did not appear visible. You can use LayerViewStateChanged to check for the layer's status/error and also update Viewpoint using Layer's full extent. 

MichaelStruk
New Contributor II

Thank you so much!  Really appreciate your help here.

0 Kudos
FaiyazKhan2
New Contributor II

Hi Jennifer,

I am facing the same problem in UWP project while trying to load offline raster package.
It show "No data" error in e.LayerViewState.Status once loading is done.
The same piece of code works in WPF project template.


Any help is appreciated.

Thanks,

Faiyaz 

0 Kudos
AnttiKajanus1
Occasional Contributor III

I have seen that error in situations where the .tpk file exists but it actually doesn't have any data in. This might occurs when you are generating tpk and something funny in the  middle. Make sure that you check that the tpk file actually has some data in side (size of the file is larger than 0). Let me know if that helps.

0 Kudos
FaiyazKhan2
New Contributor II

Yeah, it could be an issue when there is no data, however I tried with the attached layer.tpk file by Michael and the same piece of code works with WPF project but not with UWP project.