Select to view content in your preferred language

Nothing appears on the pop up!!

483
2
Jump to solution
12-22-2022 03:22 AM
KARIMLABIDI
Occasional Contributor

Hello everybody, i'm newbie on JS for arcgis. I'm trying to query by the search default widget, intersecting the result to a feature layer and get few attributes in the pop up.

I think I see the goal but nothing appears on my pop up. I got results but even the title doesn't appear!

KARIMLABIDI_0-1671707918945.png

Is there something wrong on my code? Do I have to use a poptemplate?

I need some help. 

Thank you very much

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

The documentation for view.open indicates that when the "features" property is set, it will use their popupTemplates to render the content of the popup.  Therefore, I believe this is why your title and content are ignored.

I think the solution would go something like this:

featureLayer.queryFeatures(query).then(function(results) {
	results.features.forEach(function(graphic) {
		graphic.popupTemplate = {title:"Test",content:"{type_lieu}"};
	});

	view.popup.open({
		features: results.features,
		location: evt.result.feature.geometry.centroid
	});
});

 

 

View solution in original post

0 Kudos
2 Replies
JoelBennett
MVP Regular Contributor

The documentation for view.open indicates that when the "features" property is set, it will use their popupTemplates to render the content of the popup.  Therefore, I believe this is why your title and content are ignored.

I think the solution would go something like this:

featureLayer.queryFeatures(query).then(function(results) {
	results.features.forEach(function(graphic) {
		graphic.popupTemplate = {title:"Test",content:"{type_lieu}"};
	});

	view.popup.open({
		features: results.features,
		location: evt.result.feature.geometry.centroid
	});
});

 

 

0 Kudos
KARIMLABIDI
Occasional Contributor

Yes it works!! Thank you @JoelBennett !

0 Kudos