Disable popup when selecting graphic (4.x)

1672
2
08-02-2019 10:25 AM
JosephRhodes3
New Contributor II

Hello,

I've built an application that includes the out-of-the box Sketch Widget. I need to disable the popup for active operational layers when selecting graphics created with the widget (to delete them or use the move/reshape tools). As it is, when the user selects a graphic, it opens the popup for any active layers beneath, meaning they have to close or dock the graphic to get it out of the way before they can interact with the graphic.

I assume I need to get the mappoint based on a click event, check it against the graphic's geometry, and set enablePopup to false. Here's my stab at it (at least for polygon graphics):

map.on("click", function (evt) {
var g = tempGraphicsLayer.graphics;
for (var loopCnt = 0; loopCnt < g.length; loopCnt++) {
if((g[loopCnt].geometry).contains(evt.mapPoint)){

parcels_noLabel.enablePopup=false

}
}
});

Console shows tempGraphicsLayer as undefined (therefore can't read property "contains").

Help is much appreciated! Thanks.

0 Kudos
2 Replies
KenBuja
MVP Honored Contributor

It seems like you're coding this from a 3.x perspective. In 4.x, the map doesn't have a click event, but the mapView does. Take a look at Maps and Views | ArcGIS API for JavaScript 4.12 

Take a look at this discussion about disabling popups when using the Sketch widget: https://community.esri.com/message/746309-disable-popups-while-drawingsketching-graphics-js-api-46 

ThanHtetAung_EsriAu
Esri Regular Contributor

As complement 

Read this as well

SketchViewModel | ArcGIS API for JavaScript 4.12 

At state start 

You disabled the popup with 

view.popup.autoOpenEnabled = false;

And at state -> complete and cancel (re-enabled the popup)

view.popup.autoOpenEnabled = true;