No layerview has been found for the layer

1203
2
Jump to solution
12-16-2019 04:19 PM
BruceSchneider2
New Contributor II

I am probably missing something simple but when I try to access the Layer View of a Feature Layer using view.whenLayerView I am getting the error "No layerview has been found for the layer" .

 

I am just working on this on my local machine. Can anyone see what I have wrong?

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor

It's not working as you expect since you've put the addMany method inside the view.when function. If you also move the view.whenLayerView inside that function, it will work.

view.when(function () {
   map.addMany([pointLayer]);
   view.whenLayerView(pointLayer).then(layerView => {
      console.log("LV loaded");
   })
   .catch(function (error) {
      console.log(error);
   });
});‍‍‍‍‍‍‍‍‍

Or you can move the addMany method outside the view.when function and it will work

map.addMany([pointLayer]);
view.when(function () {
  console.log("View loaded");
});
view.whenLayerView(pointLayer).then(layerView => {
  console.log("LV loaded");
})
.catch(function (error) {
  console.log(error);
});

View solution in original post

2 Replies
KenBuja
MVP Honored Contributor

It's not working as you expect since you've put the addMany method inside the view.when function. If you also move the view.whenLayerView inside that function, it will work.

view.when(function () {
   map.addMany([pointLayer]);
   view.whenLayerView(pointLayer).then(layerView => {
      console.log("LV loaded");
   })
   .catch(function (error) {
      console.log(error);
   });
});‍‍‍‍‍‍‍‍‍

Or you can move the addMany method outside the view.when function and it will work

map.addMany([pointLayer]);
view.when(function () {
  console.log("View loaded");
});
view.whenLayerView(pointLayer).then(layerView => {
  console.log("LV loaded");
})
.catch(function (error) {
  console.log(error);
});
BruceSchneider2
New Contributor II

Perfect! Thank you.

0 Kudos