Below are pretty much 2 identical sets of code.
One set of code is called by a JimuMapviewComponent activeViewChangeHandler. Sets current JMV to correct Extent but does not reset the Home Button to needed extent. does not error. just does not do it.
The other code is called by a DataSourceComponent Render. This code sets current JMV to correct Extent AND sets the Home Button to needed extent.
See below:
When the map is switched this code fires. The map zooms to the previous saved extent(mv1Ext). Then the JimuMaptool (jsapi Home widget) is found. But the Home widget will not take the new home extent of mv1Ext (which was just used above). The Home extent defaults to all features in layer.
const activeViewChangeHandler = (jmv: JimuMapView) => {
if (jmv) {
alert(jmv.dataSourceId)
if (mapView.isActive) {
alert('mapView.isActive')
if (mv1Ext) {
jmv.view.goTo(mv1Ext)
let myViewpoint = new Viewpoint ({targetGeometry: mv1Ext})
const MapTools:JimuMapTool[] = jmv.jimuMapTools
MapTools.forEach( (element) => {
if (element.name === "Home") {
alert('found Home Widget')
element.instance.viewpoint = new Viewpoint({targetGeometry: mv1Ext})
}
})
}
}
}
}The above code is used in the jmv component render event
See successfully executing code below: This is called by a DataSourceComponent Render.
else if (myTitle.includes("Hot")) {
if (!mapView.isActive) {return}
mySQL = HZquery.where
if (myTitle.includes("Hot")) {
DL_layer.definitionExpression = mySQL
DL_layer.when(() => {
return DL_layer.queryExtent()
})
.then((response) => {
myExt = response.extent
myExt.expand(1.25)
mv1Ext = myExt
mapView.view.goTo(myExt)
const MapTools:JimuMapTool[] = mapView.jimuMapTools
MapTools.forEach( (element) => {
if (element.name === "Home") {
element.instance.viewpoint = new Viewpoint({targetGeometry: mv1Ext})
}
})
})
}
} Note the same code getting the jsapi Home widget. This code executes fine and sets the Home extent to the previously set mv1Ext.
Any ideas what is going on?
BobinTN