I'm trying to open a Popup for a feature returned from a QueryTask. If I just click on the feature in the map, then it works fine, but when the app first opens it zooms to a specific feature and I want to automatically display the popup for it.
var meterNumber_Q = new Query();
meterNumber_Q.returnGeometry = true;
meterNumber_Q.outSpatialReference = sr;
meterNumber_Q.outFields = ['*'];
meterNumber_Q.where = `gs_meter_number = '${meterNumber}'`;
mapImageLayer.findSublayerById(27).queryFeatures(meterNumber_Q).then(zoomToServicePoint);
function zoomToServicePoint(results) {
var feature = results.features[0];
view.popup.open({
features: feature,
title: '<b>Layer: </b>Service Point',
content:
'<ul><li><b>Service Status: </b>{gs_service_status}</li>' +
'<li><b>Meter Number: </b>{gs_meter_number}</li>' +
'<li><b>Access Note: </b>{AccessNotes}</li><ul>'
});
}
This opens the Popup, but it displays the Content exactly as above even though the feature contains the attributes listed inside the {}.
Why aren't the attributes being transferred?
Is there an easier way to do this since I already have the exact same information setup on the sublayer as a popupTemplate?
{
id: 27, //Service Point
visible: true,
legendEnabled: true,
title: 'Service Point',
popupTemplate: servicePopupTemplate,
},
Thanks