Select to view content in your preferred language

Vector tile layer not retaining current map extent in ArcGIS JS 4.0

1385
2
Jump to solution
07-12-2016 08:48 AM
MuktaPuri
Deactivated User


We have found this issue where if have multiple layers (including a vector layer) on the map and if we do the following, the current map extents are not applied to the vector layer:

  • Disable vector tile layer (set visible property to false).
  • Pan the map.
  • Enable the vector tile layer.
  • New map extents are not applied to the vector tile layer.

Here is a JS fiddle where you can try this out: JSFiddle

Is there a workaround/fix to this issue?

As we require multiple layers that can be enabled/disabled on the map for our project, it is critical for our project that we get this working.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

This would be a bug in 4.0. You can currently work around the issue by setting the view.extent to itself immediately after setting the visibility.

    on(layersElement, ".layers-item:click", function(e) {
      var node = document.querySelector(".layers-item");
      node.classList.toggle("visible-layer");
      tileLyr.visible = !tileLyr.visible;
      // add this line
      view.extent = view.extent;
    });

Thanks!

View solution in original post

2 Replies
ReneRubalcava
Honored Contributor

This would be a bug in 4.0. You can currently work around the issue by setting the view.extent to itself immediately after setting the visibility.

    on(layersElement, ".layers-item:click", function(e) {
      var node = document.querySelector(".layers-item");
      node.classList.toggle("visible-layer");
      tileLyr.visible = !tileLyr.visible;
      // add this line
      view.extent = view.extent;
    });

Thanks!

MuktaPuri
Deactivated User

Thank You! That worked!

0 Kudos