I have a problem when using reactiveUtils.watch to monitor the view.popup. I need to catch the graphic id
to do further customize action, but I didn't find out any infos just from view.popup object.
The code snippet is as below:
reactiveUtils.watch(
() => view.popup.visible,
(visible) => {
///debugger;
// console.log("view.popup = ");
// console.info(view.popup);
if (visible) { .... }
}
);
And another problem is, when I try using other method to get the graphic, like this:
// Event handler that fires each time an action is clicked.
reactiveUtils.on(
() => view.popup,
"trigger-action",
(event) => {
console.log("event.action.id =" + event.action.id);
});
when I use chrome to debug this, I found reactiveUtils.on is not be called. So, is there any good way to
catch popupTemplate reactor's graphic id, this graphic is basically as following:
graphic = new Graphic({
geometry: new geometry.Polygon({
rings: coordinates,
spatialReference: {
wkid: 3826
}
}),
symbol: {
type: "simple-fill",
color: [255, 0, 0, 0.3], // Red color with 0.3 opacity
outline: {
color: [255, 0, 0], // Red color
width: 1
}
},
attributes: {
Name: "simple-marker",
Description: tableHTML
},
popupTemplate: popupTemplate
});
graphic.geometry.id = "checking_graphic_1"
thanks a lot.
Solved! Go to Solution.
Sorry about that, I didn't test it before posting, and it appears that the visible property gets set before the selectedFeature property. It looks like if you reverse things to watch selectedFeature instead, you get the expected reference:
reactiveUtils.watch(() => view.popup?.selectedFeature, (selectedFeature) => {
if ((selectedFeature) && (view.popup.visible)) {
console.info(view.popup.selectedFeature.getObjectId());
}
});
You can get a reference to the popup's currently displayed graphic via the selectedFeature property.
reactiveUtils.watch(() => view.popup?.visible, (visible) => {
if ((visible) && (view.popup.selectedFeature)) {
console.info(view.popup.selectedFeature.getObjectId());
}
});
after testify, the view.popup.selectedFeature is always null, is there any other good way to meet that,
the way I use to add graphic is using graphicLayer, thanks.
Sorry about that, I didn't test it before posting, and it appears that the visible property gets set before the selectedFeature property. It looks like if you reverse things to watch selectedFeature instead, you get the expected reference:
reactiveUtils.watch(() => view.popup?.selectedFeature, (selectedFeature) => {
if ((selectedFeature) && (view.popup.visible)) {
console.info(view.popup.selectedFeature.getObjectId());
}
});