Select to view content in your preferred language

Esri JS API 4.11: No Layerview has been found for the layer

5190
1
Jump to solution
05-29-2019 01:02 AM
by Anonymous User
Not applicable

Hi,

I'm getting the error:

message: "No layerview has been found for the layer"

name: "view:no-layerview-for-layer"

 

for the FeatureLayer that's been created from the graphics using the source property. Despite it, the symbols and labels draw just fine, but I need a view to watch some properties of the view !

I'd like to know why there is no view for such layers. If you think / know that each FeatureLayer should have the view and this is a bug and require more code, please let me know, but it's a standard FeatureLayer from graphics and then on SceneView.whenLayerView is just throwing the error in the err-callback.

Codepen (follow the sample instructions -> download shapefile -> upload shapefile and watch the layerview fail in console):
https://codepen.io/anon/pen/mYGwzK?editors=1001#anon-login

Thanks!

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

Your code for `view.whenLayerView` logic is running before you add the layer to the map. LayerView for the layer will be created when the layer is loaded to the view. 

So either move your code out of the current function and place after you add the layer to the map or do something like the following then you will get the layerView back:

 map.add(featureLayer);
 view.goTo(graphics);
 
view.whenLayerView(featureLayer).then(layerView => {
 console.log('we have the layer view.')
}, (error) => {
  console.log('we dont have the layer view: ', error)
});

View solution in original post

1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

Your code for `view.whenLayerView` logic is running before you add the layer to the map. LayerView for the layer will be created when the layer is loaded to the view. 

So either move your code out of the current function and place after you add the layer to the map or do something like the following then you will get the layerView back:

 map.add(featureLayer);
 view.goTo(graphics);
 
view.whenLayerView(featureLayer).then(layerView => {
 console.log('we have the layer view.')
}, (error) => {
  console.log('we dont have the layer view: ', error)
});