Clear graphics after queryTask

226
1
Jump to solution
07-22-2020 03:00 PM
LoriEmerson_McCormack
Occasional Contributor

How do I clear graphics when I close my popup template from a queryTask result?  I would expect the symbol to be associated with the "parcelResults" because that is where I set the symbol, but it didn't show in the map until I used the map.add(graphicsLayerParcel).

 

function doQueryParcel(paramParcelID) {

// Clear the results from a previous query

graphicsLayerParcel.removeAll();

paramsQuery.where = "PID_NUM = '" + paramParcelID + "'";

// executes the query and calls getResultsParcel() once the promise is resolved

// promiseRejected() is called if the promise is rejected

qTaskParcel.execute(paramsQuery)

.then(getResultsParcel)

.catch(promiseRejected);

} // end function doQueryParcel()

function getResultsParcel(response) {

map.add(response);

// Loop through each of the results and assign a symbol and PopupTemplate

// to each so they may be visualized on the map

var parcelResults = response.features.map(function (feature) {

//var parcelResults = arrayUtils.map(response.features, function (feature) {

// Sets the symbol of each resulting feature

feature.symbol = fillSymbolSingleParcel;

feature.popupTemplate = tplParcel;

return feature;

});

graphicsLayerParcel.addMany(parcelResults);

map.add(graphicsLayerParcel );

var parcelExtent = response.features[0].geometry.extent.clone().expand(2);

// animate to the results after they are added to the map

view.goTo(parcelExtent).then(function () {

view.popup.open({

features: parcelResults,

featureMenuOpen: true,

updateLocationEnabled: true

});

});

} // end function getResultsParcel()

 

0 Kudos
1 Solution

Accepted Solutions
LoriEmerson_McCormack
Occasional Contributor

Never mind.  I had a brain freeze.  Here is what can clear the graphics when the popup is closed:

watchUtils.whenFalse(view.popup, "visible", function () {

view.graphics.removeAll();

});

View solution in original post

0 Kudos
1 Reply
LoriEmerson_McCormack
Occasional Contributor

Never mind.  I had a brain freeze.  Here is what can clear the graphics when the popup is closed:

watchUtils.whenFalse(view.popup, "visible", function () {

view.graphics.removeAll();

});

0 Kudos