Select to view content in your preferred language

JS AP! 4.0 Query Results Popup Display

3056
10
Jump to solution
08-18-2016 08:57 AM
DavidColey
MVP Regular Contributor

Hello - in continuing 3.x - 4.x functionality migraiton I'm running into some problems getting the popup to display query return results.  We (mstranovsky) 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

Tags (1)
0 Kudos
10 Replies
GertConradie
Frequent Contributor

Thanks, this resolved it for me. 

I use a popupTemplate on the sublayer that I query.

view.popup.open({
//features: [mobResult.features], => this produced the "TypeError: this.selectedFeature.getEffectivePopupTemplate is not a function" message
features: mobResult.features,
location: event.mapPoint
});

0 Kudos