Seems like there is a hitch somewhere within the Scene popup, or perhaps I'm missing something. Thanks for your help upfront.
Note: Worked ok in 4.11
I have a set of features coming from the identify task. These are the polygon graphics (but doesn't work with other geometry types as well) with proper geometry, spatial reference, symbology and attributes, the popup displays in correct location and the content gets generated ok, but the Zoom To is not working. it doesn't throw an error, it simply does nothing.
If I compare the popup features for which the popup works (e.g. from feature layer on click event), with the features I'm pushing for popup from identify, the difference is in layer and sourceLayer attributes are missing in the latter (because they come from the identify, these don't have the layer).
I can pinpoint the problem in catch of the createGoToCamera promise in the api but the arguments for that catch statement are null so not really contain any error information.
d.prototype.goToAnimated = function(a, c) {
return h(this, void 0, void 0, function() {
var e, d, g, k, l, p, m = this;
return b(this, function(q) {
this.cancelAnimatedGoTo();
if (!this.ready)
return [2, this.goToAnimatedBeforeReady(a, c)];
e = this.view.state.cameraController;
e instanceof K.PointToPointAnimationController && e.updateStateFromViewAnimation(),
e.active && (d = e));
null == d && (d = new K.PointToPointAnimationController(this.view.state,this.view.sceneIntersectionHelper));
g = d.viewAnimation;
k = this.createGoToCamera(a, c); // <- THIS IS THE PROBLEM PROMISE
...
...
...
...
...
k.then(function(a) {
...
}).catch(function(a) {
!v.isAbortError(a) && a instanceof f && a.message && T.error("#goTo()", "Failed to create camera from target, " + a.message[0].toLowerCase() + a.message.slice(1));
if (p())
throw m.view.state.cameraController.stopController(),
a;
});
and my code:
this.esriLib.all(tasks).then(resultsArray => {
const features = [];
resultsArray.forEach((results, idx) => {
if (results && results.results) {
results.results.forEach((item) => {
const feature = item.feature;
if (!feature) {
return;
}
// Set the symbol.
feature.symbol = this.mapService.getIdentifyResultSymbol(feature.geometry);
// Prepare the popup template
const template = new this.esriLib.PopupTemplate({
title: item.layerName,
content: [{
type: 'fields',
fieldInfos: Object.keys(feature.attributes).map(k => {
return {
fieldName: k,
label: k
};
})
}]
});
feature.popupTemplate = template;
features.push(feature);
});
}
});
if (features && features.length > 0) {
this.mapView.popup.open({
features: features,
location: point
});
}
Solved! Go to Solution.
So, if everyone ever finds himself/herself in the similar scenario as above, this is how I resolved it
In summary:
Init
During task execution
const template = new this.esriLib.PopupTemplate({
title: item.layerName,
content: [{
type: 'fields',
fieldInfos: Object.keys(feature.attributes).map(k => {
return {
fieldName: k,
label: k
};
})
}]
});
feature.popupTemplate = template;
feature.layer = this.identifyLayer;
feature.sourceLayer = this.identifyLayer;
this.mapView.popup.open({
features: features,
location: evt.mapPoint
});
Popup
Hook to the popup's visibility and features change events:
this.esriLib.watchUtils.watch(view.popup, 'selectedFeature', (feature) => {
this.clearPopupHighlight(view.popup);
if (feature && feature.layer && feature.layer.view && feature.layer.view.highlight) {
view.popup.highlightHandle = feature.layer.view.highlight(feature);
}
});
This is awful a lot of (async) work that needs to be done to display the identify results, display them using their own layer's renderers (real symbols), and enable popup to be able to zoom to and highlight the features.
Hope that helps.
So, if everyone ever finds himself/herself in the similar scenario as above, this is how I resolved it
In summary:
Init
During task execution
const template = new this.esriLib.PopupTemplate({
title: item.layerName,
content: [{
type: 'fields',
fieldInfos: Object.keys(feature.attributes).map(k => {
return {
fieldName: k,
label: k
};
})
}]
});
feature.popupTemplate = template;
feature.layer = this.identifyLayer;
feature.sourceLayer = this.identifyLayer;
this.mapView.popup.open({
features: features,
location: evt.mapPoint
});
Popup
Hook to the popup's visibility and features change events:
this.esriLib.watchUtils.watch(view.popup, 'selectedFeature', (feature) => {
this.clearPopupHighlight(view.popup);
if (feature && feature.layer && feature.layer.view && feature.layer.view.highlight) {
view.popup.highlightHandle = feature.layer.view.highlight(feature);
}
});
This is awful a lot of (async) work that needs to be done to display the identify results, display them using their own layer's renderers (real symbols), and enable popup to be able to zoom to and highlight the features.
Hope that helps.