Hello,
I am using 4.6 version of ESRI Javascript. I have tried to do a query and get a Popup of the resulting features, which looks similar to the Popup you would get when making click on a feature. But with no success.
I have a FeatureLayer with a JSON array as source, with a popUpTemplate applied that looks as expected. I have tried to apply this popUpTemplate to the query result, but the Popup I get after the query does not properly apply the given popUpTemplate. Fields are not matched, they look literally like in the popupTemplate.
ie: showing "ID={ID}" instead of its numeric value "ID=54"
I also thought to simulate programatically a user click, using varios techniques, but none worked. I read that emit method could be a possibility in older versions, but in 4.6 does not seem to work.
This is my code:
view.whenLayerView(foundLayer_CM).then(function(lyrView) {
// query all the features available for drawing.
lyrView.queryFeatures().then(function(results) {
results.forEach(function(element) {
var idElemento = element.attributes["IDALFA"];
if (idElemento==value_IDALFA){
var screenPoint;
var screenPoint2 = view.toScreen(element.geometry, screenPoint);
var screenX = screenPoint2.x;
var screenY = screenPoint2.y;
view.popup.features = [element];
view.popup.popupTemplate = pTemplate_CM;
view.popup.title = pTemplate_CM.title;
view.popup.location = element.geometry;
view.popup.open();
}
});
});
});
Solved! Go to Solution.
Yes, it seems to be the cause of this behavior. I thought it was also acceptable to assign properties and then call "Open" with no arguments, but I guess it's not designed to work in the same way.
Thank you so much for your help, Kelly!!! I had spent a lot of time with this issue.
Regards,
Manuel
Hi Kelly:
Do you know how I can query on a locator source and bring up data from two FeatureLayer sources instead of the locator source?
Here's what I have so far:
// Search widget
var searchWidget = new Search({
view: view,
sources: [{
locator: new Locator({ url: locatorServiceUrl }),
singleLineFieldName: "SingleLine",
name: "Place",
localSearchOptions: {
minScale: 300000,
distance: 50000
},
placeholder: "Search Places",
maxResults: 3,
maxSuggestions: 6,
suggestionsEnabled: true,
popupEnabled: false,
minSuggestCharacters: 0
},
{
featureLayer: houseLyr,
searchFields: ["LAST_NAME", "DISTRICT"],
displayField: "LAST_NAME",
exactMatch: false,
outFields: ["*"],
name: "House Members",
maxResults: 10,
maxSuggestions: 10,
suggestionsEnabled: true,
minSuggestCharacters: 0,
placeholder: "District No. or Last Name"
},
{
featureLayer: senateLyr,
searchFields: ["LAST_NAME", "DISTRICT"],
displayField: "LAST_NAME",
exactMatch: false,
outFields: ["*"],
name: "Senate Members",
placeholder: "District No. or Last Name",
maxResults: 6,
maxSuggestions: 6,
suggestionsEnabled: true,
minSuggestCharacters: 0
}]
});
searchWidget.on("select-result", function(event){
//DEBUG
console.log(JSON.stringify(event));
if(!event.result.feature.geometry.rings)
{
view.popup.open({
title: "Feature Layer data!",
content: "Want that data here.",
location: event.result.feature.geometry
});
}
});
Any help appreciated!!