I have an ArcGIS JavaScript application which displays one single FeatureLayer on a map which is in a Dojo BorderContainer/ContentPane template similar to the one shown here. I am trying to initialize the map to the fullExtent of the single FeatureLayer. I accomplish this like so:

map.on("layers-add-result", function(evt){ 

However, I am finding that points on the extremes of the map are cut off. Specifically, this is a layer of points across the eastern and midwestern United States, but there are a few points in California and one in France. The points in CA and France are out of the map's extent.

My hunch was that the extent is set assuming there is no ContentPane side panel, then forced into the smaller viewport once the ContentPane is rendered. I tested this theory by creating a map which spans 100% of the page's width. Sure enough, the problem went away.

How can I ensure that map.setExtent() takes into account the ContentPane side panels? I'm already requiring domReady! and calling parser.parse(). Anything else I'm missing?

Edited with more details on 2/24

I forgot to add that I have a FeatureTable which basically serves as the attribute table for the points in the FeatureLayer. I have set the map to zoom back out to the full extent when the FeatureTable selection is cleared. When this zooming out occurs, the map zooms to the correct extents and includes all the points. This bolsters my theory that the initial call to map.setExtent isn't "aware" of the map's smaller viewport when the page initially loads but it is later once the page is fully loaded.


Try calling map.resize() after the ContentPane is rendered and the map div resized. You may also have to use map.reposition() depending on if the div was moved or not.

Edit, in response to your comment about making sure it goes after the ContentPane reposition:

Putting it after window.onload will make sure that it fires after everything else has completely loaded:

window.onload = function(){
  function to set your extent

That way everything will load, including the panes that cause the map div to resize, and then you resize the map and then you zoom to your desired extent.

  • I use this when adjusting my page for printing and back. Easy solution for a weird problem. – Branco Feb 24 '15 at 15:33
  • Thanks--I tried putting this within map.on("layers-add-result") but I'm still getting the same problem. I tried both map.resize() and map.reposition() before and after map.setExtent(). What's the best way to detect when the ContentPane has been rendered? Should I be putting these two lines elsewhere in the code? – George Feb 24 '15 at 15:43
  • Edited answer in response to comment... – Dan Jurgella Feb 24 '15 at 16:53
  • This works! Feels like such a hack/workaround though. Thanks for your help. – George Feb 24 '15 at 17:02
  • Yeah, I know what you mean. If anyone else has a better method, I'd love to hear it as well. – Dan Jurgella Feb 24 '15 at 17:27

I contacted Esri tech support about this question. They reminded me that the setExtentfunction takes two input variables: setExtent(extent, fit?). The fit variable is set to false by default, but according to the function documentation, it guarantees any map with tiled map service layers will "fit" on the screen.

So, I have been able to fix this issue and get the desired result with the following adjustment to the original code:

Old (wrong)

map.on("layers-add-result", function(evt){ 

New (correct)

map.on("layers-add-result", function(evt){ 
    map.setExtent(evt.layers[0].layer.fullExtent, true)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.