tjrourke

JSAPI 2.0 - InfoWindow shows up in wrong place after zoom

Discussion created by tjrourke on Aug 25, 2010
Latest reply on Aug 26, 2010 by tjrourke
I have a script to zoom and pan the map to frame two graphics - a vehicle and a destination - and then popup the map's InfoWindow for the destination graphic. The extent change works most of the time, but the InfoWindow always shows up in the wrong place. Here's the relevant code:

// destData is a data row returned from a service, used to create destGraphic.
// destGraphic is the destination graphic created and added to the graphic layer.
// vehGraphic is a vehicle graphic already present in the graphic layer.
var graphics = [];
graphics.push(destGraphic);
graphics.push(vehGraphic);
var extent = esri.graphicsExtent(graphics);
map.setExtent(extent);

map.infoWindow.hide();
map.infoWindow.setTitle(destGraphic.infoTemplate.title);
map.infoWindow.setContent(destGraphic.infoTemplate.content);
map.infoWindow.resize(350, 300);

var destPoint = new esri.geometry.Point(destData.Longitude, 
 destData.Latitude, new esri.SpatialReference({ wkid: 4326 }));
var screenPoint = map.toScreen(destPoint);
map.infoWindow.show(screenPoint, map.getInfoWindowAnchor(screenPoint));


Firebug shows two errors: "exception in animation handler for: onEnd" and "TypeError: pt is null"  which are Dojo errors that I see during the zoom and pan. They may be related to turning off the "Loading" progress animation, but I'm not sure.

I assume the InfoWindow is trying to find a point that isn't valid because the animation is changing the map coordinates or something. I've tried adding a pause of up to 10 seconds before popping it up, but the InfoWindow always pops up before or during the extent change, even though the execution order is clear in the code. I've also played with the settings esri.config.defaults.map.panDuration, esri.config.defaults.map.panRate, esri.config.defaults.map.zoomDuration and esri.config.defaults.map.zoomRate with no joy.

I'm using ArcGIS 9.3.1 and JavaScript API 2.0 (not Flex, Google or Virtual Earth). Results are the same in Internet Explorer 7 and 8 and in FireFox.

Does anyone know a tweak or other work-around to fix this?

Outcomes