Clear Buffer when closing geoprocessing widget and when reopening geoprocessing widget, display default values

1024
2
Jump to solution
01-30-2017 04:50 AM
Labels (1)
GilbertoMatos
Occasional Contributor II

Hello!

How do I do when the geoprocessing widget when it is closed, clear all created buffers, or how to do it whenever the geoprocessing widget is opened, it is with the default values, ie as if it had been opened by the first time?

Thank you!
Gilberto.

0 Kudos
1 Solution

Accepted Solutions
GilbertoMatos
Occasional Contributor II

Hello

I was able to perform such an operation. For this, I created a function that follows below. I am Brazilian, so the comments are in Portuguese from Brazil.

Thank you!

_limpaBuffer: function()
                {
                    //Remove os pontos do mapa, camadas de buffer, a aba do
                    //buffer criada no attribute table, seta o mapa para um
                    //extent default e executa zoom.                    
                    this.graphicClickBufferLayer.clear();
                    this.graphicClickPointLayer.clear();
                    this.graphicResultLayer.clear();                    
                    this.map.graphics.clear();
                    //window.location.reload(false);
                    
                    //Remove as camadas gráfica de buffer (todas camadas que iniciam por Buffer_)
                    var camadasMapa = this.map.graphicsLayerIds.length
                    for (var j = camadasMapa - 1; j >= 0; j--)
                    {    
                        var camada;

                        camada = this.map.getLayer(this.map.graphicsLayerIds);                                                                                    
                        if (camada.name)
                        {                                                    
                            if (camada.name.substring(0, 7) == "Buffer_")
                            {
                                this.map.removeLayer(camada);
                            }  
                        }                            
                    }   
                                                                                                                    
                    //Centraliza o mapa no extent padrão
                    //var spatialRef = new SpatialReference({ wkid:4674 });
                    //var spatialRef = new SpatialReference({ wkid:102100 });
                    var startExtent = new Extent();
                    startExtent.xmin = -57.643884794;
                    startExtent.ymin = -33.752081271;
                    startExtent.xmax = -49.691351788;
                    startExtent.ymax = -27.082302022;
                    //startExtent.spatialReference = spatialRef;
                    this.map.setExtent(startExtent);
                    
                    //Fecha (minimiza) o attribute table
                    this.wManager = WidgetManager.getInstance();                        
                    if (this.wManager)
                    {
                        var widgetCfg = this._getWidgetConfig('AttributeTable');
                        
                        if (widgetCfg)
                        {
                            var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
                            if (attWidget)
                            {
                                attWidget._closeTable();
                            }
                        }
                    }
                }

View solution in original post

0 Kudos
2 Replies
LefterisKoumis
Occasional Contributor III

The drawn buffers on the map are graphicslayers. Just in the onclose() function remove them like any other layers

map.removeLayer(GraphicsLayer)

GilbertoMatos
Occasional Contributor II

Hello

I was able to perform such an operation. For this, I created a function that follows below. I am Brazilian, so the comments are in Portuguese from Brazil.

Thank you!

_limpaBuffer: function()
                {
                    //Remove os pontos do mapa, camadas de buffer, a aba do
                    //buffer criada no attribute table, seta o mapa para um
                    //extent default e executa zoom.                    
                    this.graphicClickBufferLayer.clear();
                    this.graphicClickPointLayer.clear();
                    this.graphicResultLayer.clear();                    
                    this.map.graphics.clear();
                    //window.location.reload(false);
                    
                    //Remove as camadas gráfica de buffer (todas camadas que iniciam por Buffer_)
                    var camadasMapa = this.map.graphicsLayerIds.length
                    for (var j = camadasMapa - 1; j >= 0; j--)
                    {    
                        var camada;

                        camada = this.map.getLayer(this.map.graphicsLayerIds);                                                                                    
                        if (camada.name)
                        {                                                    
                            if (camada.name.substring(0, 7) == "Buffer_")
                            {
                                this.map.removeLayer(camada);
                            }  
                        }                            
                    }   
                                                                                                                    
                    //Centraliza o mapa no extent padrão
                    //var spatialRef = new SpatialReference({ wkid:4674 });
                    //var spatialRef = new SpatialReference({ wkid:102100 });
                    var startExtent = new Extent();
                    startExtent.xmin = -57.643884794;
                    startExtent.ymin = -33.752081271;
                    startExtent.xmax = -49.691351788;
                    startExtent.ymax = -27.082302022;
                    //startExtent.spatialReference = spatialRef;
                    this.map.setExtent(startExtent);
                    
                    //Fecha (minimiza) o attribute table
                    this.wManager = WidgetManager.getInstance();                        
                    if (this.wManager)
                    {
                        var widgetCfg = this._getWidgetConfig('AttributeTable');
                        
                        if (widgetCfg)
                        {
                            var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
                            if (attWidget)
                            {
                                attWidget._closeTable();
                            }
                        }
                    }
                }

0 Kudos