I put together a search widget, and I'm trying to get it to show the embedded webmap popup when I click my search result. Robert's ESearch does this but I'm not seeing where it shows the embedded webmap popup that I already configured in the webmap using arcgis portal. Any direction would be wonderful. Thanks!
Dean
Dean,
Is this a question for a WAB app of just a JS API app?
Well I'm putting the code in a custom WAB app. I can refilter the question under the WAB app if that helps..
Dean,
I have moved this thread to the WAB space.
I put together a search widget
The easy way to programatically fire a map click event:
var currentMapCenter = this.map.extent.getCenter();
var scrPnt = this.map.toScreen(currentMapCenter);
this.map.emit("click", {mapPoint: currentMapCenter, screenPoint: scrPnt});
The way I do it in my eSearch is assign the web map layers popupTemplate to my search results infoTemplate property:
array.forEach(this.operLayerInfos.getLayerInfoArray(), function(layerInfo2) {
//console.info(layerInfo2);
if(layerInfo2.layerObject && layerInfo2.layerObject.url === layerInfo._origServiceURL || layerInfo2.layerObject.url === layerInfo._origLayerURL){
//console.info(layerInfo2);
if(layerInfo2.controlPopupInfo.hasOwnProperty("infoTemplates")){
if(layerInfo2.controlPopupInfo.infoTemplates[layerInfo.id]){
//console.info(layerInfo2.controlPopupInfo.infoTemplates[layerInfo.id].infoTemplate);
if(layerInfo2.controlPopupInfo.infoTemplates[layerInfo.id].infoTemplate._fieldLabels){
_popupNeedFields = this._addPopupFields(layerInfo2.controlPopupInfo.infoTemplates[layerInfo.id].infoTemplate._fieldLabels);
}
_infoTemplate = layerInfo2.controlPopupInfo.infoTemplates[layerInfo.id].infoTemplate;
_hasInfoTemplate = true;
}else{
_hasInfoTemplate = false;
}
}else{
if(layerInfo2.controlPopupInfo.infoTemplate._fieldLabels){
_popupNeedFields = this._addPopupFields(layerInfo2.controlPopupInfo.infoTemplate._fieldLabels);
}
_infoTemplate = layerInfo2.controlPopupInfo.infoTemplate;
_hasInfoTemplate = true;
}
}
}, this);
...
resultLayer._hasInfoTemplate = true;
resultLayer.infoTemplate = _infoTemplate;
Hey Robert,
Thanks for moving the question for me. I appreciate that.. To answer your two questions:
1) Correct, custom widget using QueryTasks
2) Yes I have it returning the geometry.
I was hoping not to have to finagle a map click to display the popup. I figured there was a way to call a specific popup based on the search result (whether it is geometry or otherwise).
My reasoning for this is my custom search tool could search up to 20 different layers... as well as a small part of it (using the DrawBox) sending back results searching up to all of these results. The rub with this is Each layer has some of the same data, some different pieces of data. I wanted to show a list of results that are normalized for all layers, (like ID and description) then when someone clicks on that result item display the popup out of the layer it came out of. Hopefully this makes sense. I can attempt to use the programmatic map click as you mentioned.. I'll give it a run and let you know... Unless you have other thoughts..
Dean,
My second code snippet is to assign the actual layers popup to your search results layer. That is the best option.
I'll give it a go around and see what I come up with. Thanks Robert..