MapView.goTo() is changing MapView.animation always with Javascript API 4.12

1424
4
Jump to solution
10-11-2019 07:17 AM
MichailMarinakis1
Occasional Contributor II

Hi all, 

we were using version 4.11 of the Javascript API. We are watching the MapView.animation property for changes.

When we run the following command: MapView.goTo({target: point, scale:100}, { animate: false });

no changes on the state of the animation property are occurring and that is the expected behavior (I guess). 

We upgraded to version 4.12  of the Javascript API. The MapView.animation property is changing always independent of the value GoToOptions2D.animate

Is there a workaround for that? Or do we miss something? 

Thanks!

Michalis

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

I tested the sample provided and yes, when the app initially loads, that updateLocationEnabled: true pans the map and that means the view is animated. After initial load, the view.animation behavior remains the same whether the updateLocationEnabled is true or false, which makes sense. Does this address your question?

View solution in original post

4 Replies
Noah-Sager
Esri Regular Contributor

Hi Michalis, do you have a sample or reproducible test app that demonstrates this?

0 Kudos
MichailMarinakis1
Occasional Contributor II

Hi Noah, 

thank you for the fast response. I think I have found the reason and it is not the goTo().

Before calling the goTo() function, I was calling the:

MapView.popup.open({features: selectedFeatures, updateLocationEnabled: true}).

The flag updateLocationEnabled is change the state of animation.

Please find below a small sample to reproduce it. I assume that this is an expected behavior, right?

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  <title>Sample</title>
  <style>
    html,
    body,
    #viewDiv {
      padding0;
      margin0;
      height100%;
      width100%;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.13/esri/themes/light/main.css" />
  <script src="https://js.arcgis.com/4.13/"></script>

  <script>
    require(["esri/Map""esri/views/MapView""esri/layers/FeatureLayer"], function (MapMapViewFeatureLayer) {
      var map = new Map({
        basemap: "streets"
      });

      var view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 4,
        center: [1565
      });

      var featureLayer = new FeatureLayer({
        url:
          "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0"
      });

      var query = featureLayer.createQuery();
      query.where = "tree_id = 102";

      featureLayer.queryFeatures(query)
        .then((response=> {
          view.popup.open({
            features: response.features,
            // if we set this flag to false, the state of animation will not change
            updateLocationEnabled: true
          });
        });

      view.watch("animation"function (response) {
        if (response && response.state === "running") {
          console.log("Animation in progress");
        }
        else {
          console.log("No animation");
        }
      });
    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>

</html>
0 Kudos
Noah-Sager
Esri Regular Contributor

I tested the sample provided and yes, when the app initially loads, that updateLocationEnabled: true pans the map and that means the view is animated. After initial load, the view.animation behavior remains the same whether the updateLocationEnabled is true or false, which makes sense. Does this address your question?

MichailMarinakis1
Occasional Contributor II

Yeap, thanks again for the fast responses and clear answer!