I am trying to set map extent using an offset because there is a panel floating over the left side of the map and sometimes, when I zoom to a feature extent, the feature is partly hidden behind it.
I would like the extent to be always displayed and CENTERED in the map section that is not hidden by the panel
For instance the normal behavior is like below, but some of the feature is hidden behind the panel:
I would like to find a way to center the feature in the map section that is not hidden by the panel like the red rectangle below:
This is what I tried so far without success:
function zoomToExtent(extent) {
var hiddenMapPartTopLeft = map.toMap(new ScreenPoint(0, 0)),
hiddenMapPartBottomRight = map.toMap(new ScreenPoint(panel.position.left + panel.position.width, map.container.offsetHeight));
var dx = new Extent({
xmin: hiddenMapPartTopLeft.x,
ymin: hiddenMapPartBottomRight.y,
xmax: hiddenMapPartBottomRight.x,
ymax: hiddenMapPartTopLeft.y,
spatialReference: map.spatialReference
}).getWidth();
extent = extent.offset(dx, 0);
map.setExtent(extent);
}
The map zoom way too far to the right.
Is there a solution for this?