WAB Near Me Widget

3727
23
07-21-2016 10:35 AM
Fahad_Dalbouh
New Contributor II

Good Afternoon All,

I Have a question about NearMe widge. After, the Near Me Widget reports the list of features within it's buffer distance, I decided to move to another widget, but the buffere and the symbols still floats and I couldn't know how to trurn them off. 

Is it possible to control them on the widget configuratio.

Any help is appreciated.

23 Replies
RobertScheitlin__GISP
MVP Emeritus

Fathad,

If you are using WAB Developer version than you can add some code to get graphics to hide when the widget is hidden:

onOpen: function () {

      if (this._isValidConfig) {

        this._onWindowResize();

        this._connectMapEventHandler();

      }

      if(this._highlightGraphicsLayer){

        this._highlightGraphicsLayer.show();

      }

      if(this._bufferGraphicLayer){

        this._bufferGraphicLayer.show();

      }

    },

onClose: function () {

      if (this._isValidConfig) {

        this._disconnectMapEventHandler();

      }

      if(this._highlightGraphicsLayer){

        this._highlightGraphicsLayer.hide();

      }

      if(this._bufferGraphicLayer){

        this._bufferGraphicLayer.hide();

      }

    },

If you are using the AGOL version then your only option is to click the clear button on the Search dijit inside the NearMe widget UI.

Fahad_Dalbouh
New Contributor II

Hello Robert,

Thanks for your early response.I'm actually using the AGOL version. I also didn't find the clear button you mention on the Search dijit inside the NearMe widget.

Does ESRI have plans to update this widget with the code you provide in AGOL version?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Fadhad,

   This is the clear button I was talking about.

example.jpg

You should have this in the AGOL Version.

0 Kudos
DavidColey
Frequent Contributor

Hi Robert - where are you adding this code?  Clearing the search handles the search point graphic visibility but not the buffer.  I can't seem it to clear on either a widget panel close or search clear-

Thanks

David

0 Kudos
DavidColey
Frequent Contributor

Ah nevermind - found it in the widget.js

DavidColey
Frequent Contributor

Hi Robert et al - fyi in the onClose function I am clearing the bufferGraphicLayer as opposed to hiding:

if(this._bufferGraphicLayer){ //clearthe buffer on widget close
 this._bufferGraphicLayer.clear();
 }

as hiding restors the graphic back in the onOpen bufferGraphicLayer.show method.  This way there is nothing to show, which is what I want in my case.  It would be nice however if clearing the address search handled clearing the buffer.

David 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

David,

   so just add that to the _clearResults function then.

DavidColey
Frequent Contributor

Oh yes that works, duh. I'm still seeing some funny visibility behavior on result layers if the location result is cleared while the result is selected.  If the setting 'Only draw selected layer results' widget option is enabled, and the result is cleared, then only the selected feature from the layer will draw, not all the features.

At this point, users just have to make sure that they do not clear search results with an active selection or they will no longer be able to see the entire layer unless they do a browser refresh.  Here you can see I have 2 schools returned

if I clear the result, only the 2 schools will show in any subsequent layer list toggle action unless I redo a search.  I guess the widget is not releasing the itemlist?  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

David,

    to fix that you need to add this to the _clearResults function too:

if(this._itemListObject && this._itemListObject._selectedLayer){
  this._itemListObject._resetFilter(this._itemListObject._selectedLayer.layerIndex);
}

junshan_liu-esristaff‌ The Near Me widget seems to have things that are not working properly or just need some more work.

I think the addition of a clear link/button is really needed.