require([
"esri/Map",
"esri/core/watchUtils",
"esri/Viewpoint",
"esri/views/MapView"
], function(ArcGISMap, watchUtils, Viewpoint, MapView) {
const { whenFalse } = watchUtils;
const KEY = "JSAPI-VIEW";
const vpString = localStorage.getItem(KEY);
let vp = {};
if (vpString) {
vp = JSON.parse(vpString);
}
const map = new ArcGISMap({
basemap: "streets"
});
const view = new MapView({
container: "viewDiv",
map: map,
viewpoint: Viewpoint.fromJSON(vp)
});
whenFalse(view, "updating", () => {
const currPoint = view.viewpoint.toJSON();
localStorage.setItem(KEY, JSON.stringify(currPoint));
});
});