Select to view content in your preferred language

InfoWindow.show + set extent w/out zoom

978
1
02-16-2011 07:20 AM
CoreyAlix
Regular Contributor
When I set the extent then show an InfoWindow I get an exception.  The cause of the exception is the map._infoWindowIsShowing === true but the map._infoWindowCoords === null.

This code documents the problem (I introduced the c variable):

        esriMap._infoWindowExtentChangeHandler = function (_513, _514, _515) {
            // avoids failure but too soon for toMap (the window will miss the mark).
            if (this._infoWindowIsShowing) {
                var c = this._infoWindowCoords || // this is null
                     this.toMap(new esri.geometry.Point(this.infoWindow.coords));
                var _516;
                if (_515) {
                    _516 = this.toScreen(c);
                } else {
                    _516 = this.infoWindow.coords.offset(_514.x, _514.y);
                }
                this.infoWindow.show(_516, this.getInfoWindowAnchor(_516), true);
            }
        };

_infoWindowZoomStartHandler is the only place which assigns a value to _infoWindowCoords.  _infoWindowShowHandler sets _infoWindowIsShowing = true.

It's was hard to determine why this condition arose without the ability to step through the source but I *think*:

_infoWindowZoomStartHandler is not connected until the InfoWindow is first shown.  If this happens after the setExtent but before the animation completes, then the onExtentChange fires with a null value in _infoWindowCoords.

A likely workaround is to provide a geographic coordinate instead of screen coordinate but I'm not sure that'll work with offset, if at all. 

Any advice is appreciated.
0 Kudos
1 Reply
CoreyAlix
Regular Contributor
Explicitly assigning a value to _infoWindowCoords seems to do the trick:

        w = map.infoWindow,
        anchor = map.getInfoWindowAnchor(screenPnt);
        map._infoWindowCoords = map.toMap(screenPnt);
        w.show(screenPnt, anchor);
0 Kudos