I'm having some problems setting the Map
extent using ArcGIS API for JavaScript 3.18.
Whenever I call setExtent
with myExtent
, the Map ends up at some extent that is close to, but significantly different than myExtent
. For example I call setExtent
with:
myExtent = Object {type: "extent", xmin: -13486723.42416174, ymin: 6046817, xmax: -11828314.857440159, ymax: 8563452}
Then I handle the extent-change
event to log the actual extent:
actualExtent = Object {type: "extent", xmin: -13334853.828803658, ymin: 6277279.110955888, xmax: -11980184.45279824, ymax: 8332989.889044112}
In this example the actualExtent
is significantly more zoomed in than myExtent
. But sometimes it's more zoomed out, sometimes it's more north, etc. Basically the Map seems to be snapping myExtent
to certain zoom levels and positions.
Our server is ArcGIS Server 10.4.1. I have an ArcGIS API for Silverlight client connected to the same server doing the same work but it doesn't have this snapping problem. Can anyone suggest why this is happening and how to stop it?
UPDATE: To clarify how I build and set myExtent
, it goes a little like this:
let myExtent = angular.copy(this.map.extent);
myExtent.xmin = -13486723.42416174; // calculated
myExtent.ymin = 6046817; // calculated
myExtent.xmax = -11828314.857440159; // calculated
myExtent.ymax = 8563452; // calculated
this.map.setExtent(myExtent);
setExtent
I get the currentMap.extent
, clone it withangular.copy
, then set the xmin, xmax, ymin, ymax properties. I figured this was the safest way not to break anything. Could this actually be causing a problem?snapToZoom
setting in [version 4.1][2] that defaults to true. I'm pretty sure this is exactly what I'd like to set to false to fix my problem. But version 3.18 doesn't have this setting so I think I'm out of luck. [2]: developers.arcgis.com/javascript/latest/api-reference/…