AnsweredAssumed Answered

JS AP! 4.0 Query Results Popup Display

Question asked by dcoley on Aug 18, 2016
Latest reply on Jun 6, 2017 by straatvark

Hello - in continuing 3.x - 4.x functionality migraiton I'm running into some problems getting the popup to display query return results.  We (Michael Stranovsky) have a setup sort of like a near me, where we're returning a an intersect based on the search select-result event.  In 3.x it's really straight-forward:

 

s.on("select-result", showResults);
function showResults(evt) {

mapMain.graphics.clear();

if (evt.source.name == "Search by Address" || evt.source.name == "Search by Street") { //s.activeSource.name
console.log(evt.source.name);

qPoint = evt.result.feature.geometry;
buffer = geometryEngine.geodesicBuffer(qPoint, [1], 9035, true);
//console.log(qPoint); //console.log(buffer);
var symbol = new SimpleFillSymbol();
symbol.setColor(new Color([100,100,100,0.15]));
symbol.setOutline(null);

var graphicPoly = new Graphic(buffer, symbol);
mapMain.graphics.add(graphicPoly); //geometry

var queryTran = new Query;
queryTran.geometry = buffer;
var tranQuery = lyrMobBnds.selectFeatures(queryTran, FeatureLayer.SELECTION_NEW);
myPopup.setFeatures([tranQuery]);
myPopup.show(qPoint); //buffer
}

always worked really well, pass the event point into the geometry engine, buffer it, pass that geom to the query, select the feautures, pass and show the popup.

 

For 4.x, here's what I'm doing:

 

app.search.on("select-result", showResults);
function showResults(evt) {
app.activeView.graphics.clear;

if (evt.source.name == "Search by Address" || evt.source.name == "Search by Street") { //s.activeSource.name
console.log(evt.source.name);

qPoint = evt.result.feature.geometry;
buffer = geometryEngine.geodesicBuffer(qPoint, [1], 9035, true);
//console.log(qPoint); //console.log(buffer);
var symbol = new SimpleFillSymbol({
color: [100,100,100,0.15],
style: "solid",
outline: { // autocasts as esri/symbols/SimpleLineSymbol
color: "white",
width: 0
}
});

var graphicPoly = new Graphic(buffer, symbol);
app.activeView.graphics.add(graphicPoly); //geometry

var queryTran = new Query;
queryTran.geometry = buffer;
var tranQuery = lyrMobBnds.queryFeatures(queryTran).then(function(mobResult) { //, FeatureLayer.SELECTION_NEW);
console.log(mobResult);
app.activeView.popup.open({
features: [mobResult],
location: qPoint//result.geometry.centroid
});
});

 

consol.log are clearly showing a result, but I cannot get the result to open in the poup.  I keep getting a type error:

"TypeError: this.selectedFeature.getEffectivePopupTemplate is not a function"

 

I am not entirely certain I have my query setup correctly, but since the console log is showing the selectedFeature.  Any insight is appreciated-

Thanks

David

Outcomes