[GIS] ny Map event fired when map is loaded completely when a device is oriented from portrait to landscape mode

arcgis-javascript-apijavascript

We are using ESRI ArcGIS JavaScript API in one of our Mobile web applications. When the map is loaded for the first time an Onload event is fired. But when we change orientation from Portrait to Landscape, the OnLoad event does not get fired. We need such event so that when a map is completely loaded in Landscape mode we can perform some operation.

We know that there is Orientation change event in JavaScript but we need an event which should fire when the map is loaded completely in Landscape mode after orientation change event is fired.

Best Answer

You're probably looking for the onUpdateEnd event. It fires after all the map layers have been updated. You wouldn't want it to fire every time the map finished updating, so you would probably want to remove the event listener after it fires.

function orientationChangedOrMapDivChanged (event) {
  var updateListener = map.on("update-end", function (err) {
     // do something
     updateListener.remove();
  });
  map.resize();
  map.reposition();
}