I've set up a feature layer with a popup and added it to my map. I'm also making the feature layer searchable via the search widget. When I search and select a result, the popup opens, and the title is fine, but the content is missing. Here's a demo:
https://codepen.io/anon/pen/dJgxVQ?editors=1000
When I search for district '2003' I get this (incorrect, no content):
When I simply click on the feature, I get this (correct):
When poking around in the debugger, I see that when the popup has no content, popup.selectedFeature.layer is null. What's going on here? I simply want the same popup to show up if I click the feature or search. Thanks for any help you can provide!!
Solved! Go to Solution.
Brandon,
You have to be careful as JS is a case sensitive language. You had:
var congress = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
popupTemplate: { // autocasts as new PopupTemplate()
title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
content: "{Name} {Party}",
overwriteActions: true
}
});
Which should have been:
var congress = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
popupTemplate: { // autocasts as new PopupTemplate()
title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
content: "{NAME} {PARTY}",
overwriteActions: true
}
});
Notice field names are upper case in the content property now.
Brandon,
You have to be careful as JS is a case sensitive language. You had:
var congress = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
popupTemplate: { // autocasts as new PopupTemplate()
title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
content: "{Name} {Party}",
overwriteActions: true
}
});
Which should have been:
var congress = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
popupTemplate: { // autocasts as new PopupTemplate()
title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
content: "{NAME} {PARTY}",
overwriteActions: true
}
});
Notice field names are upper case in the content property now.
Excellent! I knew it must be something silly. Thanks Robert