0

So I am doing some excercises in the DevLab from the ArcGIS developer platform. I did an excercise in which you load a layer from the ArcGIS Online portal. Their example code is the following (it works like a charm);

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Portal;
namespace LoadAnItemFromArcGISOnline
{
/// <summary>
/// Provides map data to an application
/// </summary>
public class MapViewModel : INotifyPropertyChanged
{
 public MapViewModel()
 {
 InitializeMap();
 }
 private Map _map = new Map(Basemap.CreateTopographic());
 /// <summary>
 /// Gets or sets the map
 /// </summary>
 public Map Map
 {
 get { return _map; }
 set { _map = value; OnPropertyChanged(); }
 }
 /// <summary>
 /// Raises the <see cref="MapViewModel.PropertyChanged" /> event
 /// </summary>
 /// <param name="propertyName">The name of the property that has changed</param>
 protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
 {
 var propertyChangedHandler = PropertyChanged;
 if (propertyChangedHandler != null)
 propertyChangedHandler(this, new PropertyChangedEventArgs(propertyName));
 }
 public event PropertyChangedEventHandler PropertyChanged;
 private async void InitializeMap()
 {
 // Create a portal
 ArcGISPortal portal = await ArcGISPortal.CreateAsync();
 // Hold a portal item ID
 String portalItemId = "883cedb8c9fe4524b64d47666ed234a7";
 // Create the portal item
 PortalItem portalItem = await PortalItem.CreateAsync(portal, portalItemId);
 // Create the layer
 FeatureLayer layer = new FeatureLayer(portalItem, 0);
 // Ensure the layer is loaded
 await layer.LoadAsync();
 // Create the map with updated basemap and initial viewpoint
 this.Map = new Map(Basemap.CreateTopographic()) { InitialViewpoint = new Viewpoint(layer.FullExtent) };
 // Add the layer to the map
 this.Map.OperationalLayers.Add(layer);
 }
}
}

However, I wanted to try using a different layer. The layer I tried it with is a public layer created by the dutch government. It is a layer showing the heights of the netherlands. http://www.arcgis.com/home/webmap/viewer.html?webmap=4feca304f23847feae20eec8fec76fd8

So I simply replaced the ID of the tutorial with the ID from the Dutch layer and it gives me an error with the await layer.LoadAsync();

It sais the following: Esri.ArcGISRuntime.ArcGISRuntimeException: 'Invalid response'

It does show a map with an esri basemap with a global extent. but the app is none responsive.

The entire excercise is done in Visual studio with ArcGIS runtime sdk for .net extension.


So what I'm thinking is that the dutch layer has a different coordinate system or maybe the layer has a maximum scale, or maybe the issue is that the data is raster. Does anyone has a tip/ know how to fix it, so that I can display this layer and maybe eventually more dutch layers?

JGH
44.4k3 gold badges49 silver badges95 bronze badges
asked Jun 20, 2018 at 7:57

1 Answer 1

2

Portal items can contain multiple different types of content. Where in the example the item contains a Feature Service (item represents a service endpoint that has trailhead features) and provides metadata to describe the content based on the common portal item metadata model.

enter image description here

The second item contains a webmap. Webmaps (or maps) are items that contain the full map definition including Basemaps and Operational layers. Compared to the item that only contains a single layer, maps can be describe/author the whole map.

enter image description here

So the reason why your code doesn't work is that you try to create a Feature Layer from Map. You can use PortalItemType enum to check which type the item is.

 if (portalItem.Type == PortalItemType.FeatureService)
 {
 // it's a feature service
 // Create the layer
 FeatureLayer layer = new FeatureLayer(portalItem, 0);
 // Ensure the layer is loaded
 await layer.LoadAsync();
 // Create the map with updated basemap and initial viewpoint
 Map = new Map(Basemap.CreateTopographic()) { InitialViewpoint = new Viewpoint(layer.FullExtent) };
 Map.OperationalLayers.Add(layer);
 }
 if (portalItem.Type == PortalItemType.WebMap)
 {
 // Create map from a map definition
 Map = new Map(portalItem);
 }
answered Jun 20, 2018 at 9:27
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.