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);
Best Answer
If you'd like a guarantee that the input extent will be shown completely on the map when calling
setExtent()
you should pass the valuetrue
as the second (optional) fit parameter.https://developers.arcgis.com/javascript/3/jsapi/map-amd.html#setextent