Select to view content in your preferred language

Track Component - cannot set rotationEnabled

184
2
03-14-2025 01:41 AM
FC_Basson
MVP Alum

With the 4.32 release of the Javascript SDK, the Track widget has become deprecated and the Track component is preferred.  With the old widget you could set the rotationEnabled property, but there is no  similar option with the web component.   Is there any way to control the view rotation with the new web component?  The TrackViewModel also lacks a property to set the rotation option.

0 Kudos
2 Replies
AndyGup
Esri Regular Contributor

@FC_Basson, thanks for the heads-up. I'll open an issue to get that added at 4.33. I'm not sure why the property didn't get exposed in the component.

Edvinas_S
Esri Contributor

You can do a workaround by getting to the viewModel or by using the override functionality.

const arcgisTrack = document.querySelector("arcgis-track");
arcgisTrack.addEventListener("arcgisReady", (event) => {
  // 1. hacky way to disable rotation
  arcgisTrack._store.viewModel.rotationEnabled = false;
  
  // 2. or you can override the goTo function
  arcgisTrack.goToOverride = function(view, goToParams) {
    // 2.1 set any rotation
    goToParams.target.rotation = 80;
    
    // 2.2 or delete the parameter to keep current rotation
    // setting rotation to null will reset to 0
    delete goToParams.target.rotation;
    
    return view.goTo(goToParams.target, goToParams.options);
  };
});