AnsweredAssumed Answered

How to display popup on layer 'selection-complete' event

Question asked by alterwiel on Aug 23, 2015
Latest reply on Aug 24, 2015 by kenbuja

I'm trying to get a popup to display on a selection-complete event of a feature layer. I'm having a problem where at the line to show the window I get a "Cannot read property 'toScreen' of undefined" error in the console. Does anyone know of a better way of showing a popup from a 'selection-complete' event? Thanks.

 

featureLayer.on("selection-complete", showInfo);

function showInfo (event) {

            map.infoWindow.setFeatures(event.features);

            map.infoWindow.show(map.extent.getCenter());

}

 

Message was edited by: Andrew Terwiel

 

I have it working now. Code snippets below.

 

postCreate: function () {

            this.inherited(arguments);

            this._config = this.config;

            this.map = this.map;

            this.map.infoWindow = this._customPopup;

            this.map.on("click", this._showRoadInfo);

        },

 

deferred = widget._roadFeatureLayer.selectFeatures(layerQuery,

            FeatureLayer.SELECTION_NEW, function (selected) {

            widget._roadFeatureLayer.setSelectionSymbol(widget._slsRoad);

            widget._parcelFeatureLayer.clearSelection();

            widget._zoomToRoad(selected, widget);

            var mpPt = selected[0].geometry.getExtent().getCenter();//new Point(-122, 45.6); 

            var scrPt = widget.map.toScreen(mpPt);                            

widget.map.emit("click", { selected: selected, map: widget, bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });

  });

 

_showRoadInfo: function (event) {

            var that = this._mapParams.infoWindow;

            that.setFeatures(event.selected);

            that.show(event.mapPoint, event.screenPoint);

        },

Outcomes