Select to view content in your preferred language

searchWidget use configured Popup from map services

358
2
05-01-2024 05:38 AM
PLadd
by
Frequent Contributor

When using the searchWidget, instead of using a popup template, how do I get it to open the popup that was preconfigured in the map service when published through ArcGIS Pro?   I want searchWidget to display the popup that opens when I click a feature on the map.

Thanks. 

0 Kudos
2 Replies
JoelBennett
MVP Regular Contributor

Does it work if you set the source's popupTemplate from that of the layer?  For example:

function createSource(layer) {
	var source = new LayerSearchSource({
		//etc
		layer: layer,
		popupEnabled: true,
		popupTemplate: null,
		//etc
	});

	layer.when(function() {
		source.popupTemplate = layer.popupTemplate;
	});

	return source;
}

That should work for a FeatureLayer.  If you're using a MapImageLayer, you'd have to get the popupTemplate from within the subLayers collection instead.

0 Kudos
PLadd
by
Frequent Contributor

Thanks for the reply. I tried using your suggested changes but they didn't achieve what I am trying to do.

I think the popup that I'm getting in code is the one generated off the the graphic that's being drawn by the searchWidget. After the search completes and zooms to the parcel, if I then click on the same parcel in the view, I get two popups, the same one created by the searchWidget (the graphic is still on the map) and the ArcGIS Pro configured popup from the featureLayer (the one I want to popup from searchWidget).

It seems odd to me that I can't find any sort of property setting in the javascript API that makes reference to getting the popup to open the configured settings from ArcGIS Pro. In Web AppBuilder, this is a default behavior. I downloaded one of my existing WAB sites but couldn't quite re-engineer it enough to figure out how they go about getting this popup behavior to work.

I'll keep digging and post if I find anything . . . .

 
0 Kudos