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:
Next, I go over to my Search Widget and look for an address (using a locally hosted Geocoder service):
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:
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.
Solved! Go to Solution.
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
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.
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
Thanks, Kelly. Yes- It's very clunky but I think I got it to work in my application.
Glad you got it to work. We should have a more elegant solution for this type of thing in the 4.x api.
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) {
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.
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.
Glad you're up and running again!