Bug? Editor Widget & Search Widget not playing nice together

3111
8
Jump to solution
08-17-2015 02:56 PM
SteveCole
Frequent Contributor

Having just added the Search widget into my project, I discovered some unexpected behavior. My app is patterned after this sample. To start, I add a new feature by clicking on one of the predefined options found in the editor widget:

aeInfoWindow01.jpg

Next, I go over to my Search Widget and look for an address (using a locally hosted Geocoder service):

aeInfoWindow02.jpg

I close the geocoded popup and clear the contents of the widget by clicking the X in the input field. Now, if I go back to the point I previously created (or any other feature for that matter), the infoWindow that comes up is a copy of the geocoded result infoWindow:

aeInfoWindow03.jpg

That's pretty weird. The only way to "reset" things is to reload the page.

It's bad enough I can't use custom infoWindows when I using the Editor widget but this makes things even worse.

0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

In order to resolve these type of conflicts you need to destroy and recreate the Editor after closing the search window.  I realize this seems clunky but its the suggested approach for working with the Editor and info window content at version 3.x of the JSAPI.

To see an example of how this works look at the code starting at line 217 in this file:

edit-template/main.js at master · Esri/edit-template · GitHub

View solution in original post

8 Replies
SteveCole
Frequent Contributor

Pinging ESRI about this. I can't log a bug with support thanks to my organization & they way ESRI has set up bug reporting. This is using v3.14 of the API.

Kelly Hutchins

0 Kudos
KellyHutchins
Esri Frequent Contributor

In order to resolve these type of conflicts you need to destroy and recreate the Editor after closing the search window.  I realize this seems clunky but its the suggested approach for working with the Editor and info window content at version 3.x of the JSAPI.

To see an example of how this works look at the code starting at line 217 in this file:

edit-template/main.js at master · Esri/edit-template · GitHub

SteveCole
Frequent Contributor

Thanks, Kelly. Yes- It's very clunky but I think I got it to work in my application.

KellyHutchins
Esri Frequent Contributor

Glad you got it to work. We should have a more elegant solution for this type of thing in the 4.x api.

RickeyFight
MVP Regular Contributor

Steve,

I keep getting an error of :

Uncaught TypeError: Cannot read property 'layers' of undefined

Does your initEditing function start with this:

  function initEditing(event) {
                var featureLayerInfos = arrayUtils.map(event.layers, function (layer) {
0 Kudos
SteveCole
Frequent Contributor

Rickey Fite​ no, not any more. I was having issues with all of this so I decided to have two "apps" one for just editing and then a second one which my users would use to view the data. By doing this , I got around the need for using the initEditing function that was part of the sample in my original post.

I *think* you can resolve your issue by doing this:

map.on("layers-add-result", function(event) {

    initEditing(event);

});

In the above example, the event variable from the layers-add-result event will contain a layers collection.

RickeyFight
MVP Regular Contributor

Steve Cole,

I found a solution.

      var search = new Search({ 
        map: map,
  enableInfoWindow: false,
  enableHighlight: false,
  enableLabel: false
      }, "search"); 
      search.startup(); 

I stopped the infowindow from being created.

SteveCole
Frequent Contributor

Glad you're up and running again!

0 Kudos