I m unable to show ENC map getting error "layer could not be added to map because layer initialization failed" and "S57 dictionary not found". I have set symbols path too.

4367
31
Jump to solution
08-20-2016 04:38 AM
AnzarKhatri
New Contributor

I want to show ENC chart in my WPF app but getting these error. I have also attached screen shot of error. I have set symbols path and manifest file too but no success.

<Window x:Class="ArcGISApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
xmlns:hydro="clr-namespace:Esri.ArcGISRuntime.Hydrographic;assembly=Esri.ArcGISRuntime"
Title="MainWindow"
Height="350"
Width="525">
<Grid>
<esri:MapView x:Name="MyMapView"
LayerLoaded="MyMapView_LayerLoaded">
<esri:Map>
<!--<esri:ArcGISTiledMapServiceLayer ID="Basemap" ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>-->
<esri:GroupLayer ID="Hydrographic">
<hydro:HydrographicS57Layer ID="PK2NB58Z"
Path="US5TX51M.000">
</hydro:HydrographicS57Layer>
</esri:GroupLayer>
</esri:Map>
</esri:MapView>
</Grid>
</Window>

I think there is no issue at all in code. I dont understand what is the reason..........!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AnttiKajanus1
Occasional Contributor III

It seems that cause here is setting MapView and Maps SpatialRefernce correctly. It is normally taken from the first layer but GroupLayer doesn't have one.

Here is code that should work

<esri:MapView x:Name="MyMapView"
    LayerLoaded="MyMapView_LayerLoaded">
</esri:MapView>‍‍‍
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Hydrographic;
using System;
using System.Diagnostics;
using System.Windows;

namespace HydragraphicLayersDemo
{
    public partial class MainWindow : Window
    {

        private HydrographicS57Layer _layer;

        public MainWindow()
        {
            InitializeComponent();

            // Force to use WebMercator which is normally taken from the first layer
            var map = new Map()
            {
                SpatialReference = SpatialReferences.WebMercator,
                InitialViewpoint = new ViewpointExtent(new Envelope(0, 0, 0, 0, SpatialReferences.WebMercator))
            };

            // Create hydrographic layer and set it to the layers collection
            _layer = new HydrographicS57Layer()
            {
                ID = "US1WCO1M",
                Path = @"C:\Temp\HydragraphicLayersDemo\HydragraphicLayersDemo\bin\Debug\us1wc01m\US1WC01M.000",

            };
            map.Layers.Add(_layer);

            // Set map to view
            MyMapView.Map = map;

            // Zoom to the layer when the layer is loaded
            ZoomToHydrographicLayers();
        }

        private async void ZoomToHydrographicLayers()
        {
            try
            {
                // wait until all layers are loaded
                await MyMapView.LayersLoadedAsync();

                Envelope extent = _layer.FullExtent;

                // Zoom to full extent
                await MyMapView.SetViewAsync(extent);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred : " + ex.Message, "Sample error");
            }
        }


        private void MyMapView_LayerLoaded(object sender, LayerLoadedEventArgs e)
        {
            if (e.LoadError == null)
                return;

            Debug.WriteLine(string.Format("Error while loading layer : {0} - {1}", e.Layer.ID, e.LoadError.Message));
        }
    }
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

31 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

It sounds like the hydrographic_s57.dat file cannot be found. If you are running the app on your dev machine against the installed SDK then it should be in "C:\Program Files (x86)\ArcGIS SDKs\DotNet10.2.7\WindowsDesktop\bin\arcgisruntime10.2.7\resources\symbols\hydrographic_s57". Or if you have added a deployment manifest to your and selected to include the hydrographic option then it should be in "<your_app_folder>\arcgisruntime10.2.7\resources\symbols\hydrographic_s57". You should not need to set the symbols path unless you have included the .dat file elsewhere in your app/solution.

Can you see the dat file in either of those locations?

Cheers

Mike

0 Kudos
AnzarKhatri
New Contributor

Yes .dat file is placed in both locations. Now I have commented symbols path and getting the error "failed to load cell info".

Why there is difference in using sdk for .net and sdk for wpf? I have also seen examples for wpf sdk n  these work in totally different way as we can embed the S57Cell object inside HydrographicS57Layer. First time I m using ArcGIS sdk for .net and have never used any previous versions and also not used sdk for wpf.

Can u suggest any other to do or is there any complete sample available? the samples available to download are not compiling.......

0 Kudos
AnttiKajanus1
Occasional Contributor III

Why there is difference in using sdk for .net and sdk for wpf?

Just to clarify that ArcGIS Runtime for .NET and ArcGIS Runtime for WPF are 2 different SDKs. ArcGIS Runtime for WPF is older SDK that is replaced by ArcGIS Runtime for .NET (which contains SDKs for WPF, Windows Store and Windows Phone). ArcGIS Runtime for .NET API has been redesigned and modernized which means that the API is not the same as the old one.

Can u suggest any other to do or is there any complete sample available? the samples available to download are not compiling.......

Could you post which samples you are building? If you are using ArcGIS Runtime for .NET you should be using this repository. It has couple samples that uses hydrographic layer. Make sure that you follow these steps to get the reference changed so you can deploy the files.  Could you paste compile error information too?

0 Kudos
AnzarKhatri
New Contributor

Yes I knew that .NET sdk has been overhauled and already explored a bit. As to samples, I hate when any sample on net use NuGet package and myself is uncomfortable with it. I have downloaded right samples, first I was missing data folder which again downloaded n then the package error; mean unable to get it removed from solution.

Actually what I need in my app is that I just need to show ENC charts (.000). Do I need to be online to show this? I have attached the error screen shot in question and the code is also pasted there. Once I uncomment the line

<!--<esri:ArcGISTiledMapServiceLayer ID="Basemap".....

I dont get any error but I have to be online to show the map. I dont need this map, I have S57 ENC files and want to show these maps.

At the moment I have no urgency of compiling samples but we are exploring few SDKs and this is obviously seem to be the best. We have good experience in .NET and WPF. I m not understanding what is wrong as why I m unable to get the ENC charts rendered. If u can provide me with a separate sample to show ENC files offline, it would help us a lot as our app will always be in disconnected mode....

If there is still anything u need to explain me, let me know plz.

0 Kudos
AnzarKhatri
New Contributor

Samples compiled.................but unfortunately I have to be online to show maps

if I comment <esri:ArcGISTiledMapServiceLayer..... then I get error...

I seems .000 files cant be added with MapServer   OR????

0 Kudos
AnttiKajanus1
Occasional Contributor III

It seems that cause here is setting MapView and Maps SpatialRefernce correctly. It is normally taken from the first layer but GroupLayer doesn't have one.

Here is code that should work

<esri:MapView x:Name="MyMapView"
    LayerLoaded="MyMapView_LayerLoaded">
</esri:MapView>‍‍‍
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Hydrographic;
using System;
using System.Diagnostics;
using System.Windows;

namespace HydragraphicLayersDemo
{
    public partial class MainWindow : Window
    {

        private HydrographicS57Layer _layer;

        public MainWindow()
        {
            InitializeComponent();

            // Force to use WebMercator which is normally taken from the first layer
            var map = new Map()
            {
                SpatialReference = SpatialReferences.WebMercator,
                InitialViewpoint = new ViewpointExtent(new Envelope(0, 0, 0, 0, SpatialReferences.WebMercator))
            };

            // Create hydrographic layer and set it to the layers collection
            _layer = new HydrographicS57Layer()
            {
                ID = "US1WCO1M",
                Path = @"C:\Temp\HydragraphicLayersDemo\HydragraphicLayersDemo\bin\Debug\us1wc01m\US1WC01M.000",

            };
            map.Layers.Add(_layer);

            // Set map to view
            MyMapView.Map = map;

            // Zoom to the layer when the layer is loaded
            ZoomToHydrographicLayers();
        }

        private async void ZoomToHydrographicLayers()
        {
            try
            {
                // wait until all layers are loaded
                await MyMapView.LayersLoadedAsync();

                Envelope extent = _layer.FullExtent;

                // Zoom to full extent
                await MyMapView.SetViewAsync(extent);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred : " + ex.Message, "Sample error");
            }
        }


        private void MyMapView_LayerLoaded(object sender, LayerLoadedEventArgs e)
        {
            if (e.LoadError == null)
                return;

            Debug.WriteLine(string.Format("Error while loading layer : {0} - {1}", e.Layer.ID, e.LoadError.Message));
        }
    }
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
AnzarKhatri
New Contributor

Thnx a lot it has finally loaded. First step completed. I dont think so it is documented that it is to be used in this way!!!! Or where can I find such help? coz I still need funcntionality such as adding custom symbols, etc.

Another thing how to remove "Licensed for developer use only"???????????????

0 Kudos
AnttiKajanus1
Occasional Contributor III

I agree that the documentation could be a bit more precise with this. We will have a look and see what we can do.

To find more how to use ArcGIS Runtime, please have a look on the documentation

Guide documentation 

API reference

There is also a lot of videos available here.

To license your application have a look on this section in guide.

0 Kudos
AnzarKhatri
New Contributor

Thnx a lot for ur quick replies and hope will get more help if needed....

Do we still need to license when we are developing app for our use only with just ENC charts n we have all the charts we need?

0 Kudos