[GIS] ArcGIS JavaScript API: onAnimate Error

arcgis-10.1arcgis-javascript-apiarcgis-servermap-service

I am trying to zoom to a point in ArcGIS JavaScript API (3.9). I am doing this one of two ways, I am either grabbing a point feature from ArcGIS Server (10.1), or I am grabbing the center of a polygon and zooming to that.

I was getting an error "exception in animation handler for: onAnimate" when zooming to any point. I found here that adding a setTimeout() around your map.centerAndZoom() solves the problem. However, that was only for the point feature being brought back from the server.

The problem still persists when I try to get the center point of a polygon:

zoom to point code

I have tried both increasing and decreasing the timeout time, but I have not had any success. The map will seem to zoom to the location, but then immediate zoom back to its original location and then spit this error:

onAnimate error screenshot

I have found a little research done on "Cannot read property 'left' of undefined" and the most I could find is something about symbology – So, just to help out, here is the symbology as it is in ArcGIS Server:

Renderer:
  Simple Renderer:
  Symbol:
           Style: esriSFSSolid 
           Color: [0, 0, 0, 0] 
           Outline:
                   Style: esriSLSSolid 
                   Color: [76, 230, 0, 255] 
                   Width: 1
 Label: 
 Description:
 Transparency: 0 
 Labeling Info:

If anyone could shed some light on this problem, I would be grateful.

Best Answer

If you look at the documentation for the map.centerAndZoom function, you'll find that it requires both a point and a zoom level. Because it doesn't know how far to zoom in, it can't establish a "left" bound, "right" bound, or any bound. That is why it mentions the "left" property. Try this instead

setTimeout(function () {
    map.centerAndZoom(point, 12); // or some arbitrary number
}, 500);