Our map has a toolbar 'home' button with code that grabs extent values from a config file, creates an Extent object from those values, and passes the Extent object to the map's setExtent function. We also call this same code when the map is initialized, by calling the click function for the button. So if we load the map, then click the home button, the map image shifts about 30 or 40 pixels upward. Makes no sense, we are calling the exact same code twice in a row, with the exact same input.
Toolbar.prototype.OnFullExtentClick = function () {
var viewModel = registry.get('viewmodel');
var initial = config.Map.InitialExtent;
var extent = new esri.geometry.Extent(initial);
viewModel.Map.setExtent(extent);
};
We call it once via code in the Init function:
ViewModel.Toolbar.OnFullExtentClick();
And we execute it again when home button is clicked, via Knockout.js as below
<div id="toolbar">
<div id="zoomin" class="map-panel" data-bind="click: Toolbar.OnZoomInClick">+</div>
<div id="fullextent" class="map-panel" data-bind="click: Toolbar.OnFullExtentClick"> </div>
<div id="zoomout" class="map-panel" data-bind="click: Toolbar.OnZoomOutClick">-</div>
</div>
It doesn't seem to matter what values we set for the extent, the "jump" is always the same distance and direction (30 to 40 pixels upwards). My question(s): What are we doing wrong? How can we get it to stop doing this?
-- EDIT -- This problem is specific to IE, does not do this in Chrome. Also, still does it when the setExtent code is replaced by centerAndZoom.
Toolbar.prototype.OnFullExtentClick = function () {
var viewModel = registry.get('viewmodel');
var center = new esri.geometry.Point(717714, 972786, new esri.SpatialReference({ wkid: 2223 }));
viewModel.Map.centerAndZoom(center, 1);
};