AnsweredAssumed Answered

Setting map extent to dynamic layer's initial extent doesn't always work

Question asked by kenbuja on Jul 30, 2013
Latest reply on Sep 9, 2013 by kenbuja
I'm setting the map extent to a dynamic layer once it's loaded using the following code.

    layerDynamic.on("load", function () {         var deferred = new Deferred();         deferred = map.setExtent(layerDynamic.initialExtent, true);         deferred.then(function () {             console.log("map xmin: " + map.extent.xmin + ", ymin: " + map.extent.ymin + ", xmax: " + map.extent.xmax + ", ymax: " + map.extent.ymax)             console.log("layer xmin: " + layerDynamic.initialExtent.xmin + ", ymin: " + layerDynamic.initialExtent.ymin + ", xmax: " + layerDynamic.initialExtent.xmax + ", ymax: " + layerDynamic.initialExtent.ymax)         });     });


However, this doesn't always work. When I refresh the page, it often zooms out way too far. This is what the extents usually are when it doesn't zoom correctly

map xmin: -27374674.768619433, ymin: -2290122.0955929635, xmax: -6828401.565569537, ymax: 6241473.253482993 layer xmin: -14166895.9892999, ymin: 5762234.783315, xmax: -13598348.0746001, ymax: 6211946.863385


Why doesn't that code work upon a refresh?

Outcomes