Select to view content in your preferred language

Stop infoWindow appearing when editing

2035
17
03-27-2011 04:22 AM
MarkSmith
Occasional Contributor
Hi,

Hopefully a simple one, but I can't crack it.
I'm using the editor and template picker to allow editing of a layer through the API and this works great.  However in this instance there is no need for the infoWindow to appear when a user clicks a shape to edit, i.e. I don't want it to pop-up, I just want to be able to edit the shape, not the attributes.  So how do you prevent the infoWindow appearing?

Thank you,

Mark.
0 Kudos
17 Replies
HemingZhu
Frequent Contributor
Hi,

Hopefully a simple one, but I can't crack it.
I'm using the editor and template picker to allow editing of a layer through the API and this works great.  However in this instance there is no need for the infoWindow to appear when a user clicks a shape to edit, i.e. I don't want it to pop-up, I just want to be able to edit the shape, not the attributes.  So how do you prevent the infoWindow appearing?

Thank you,

Mark.


add map.infoWindow.hide(); in your event handler to hide the infoWindow.
0 Kudos
MarkSmith
Occasional Contributor
Hi,

Thanks for that.  What event works with this?  I have tried a few things that don't work, and I can use map.infoWindow.hide() to hide the window a split second after it appears, but not to stop it appearing in the first place.  Can you please post the code?

Thanks.
0 Kudos
HemingZhu
Frequent Contributor
Hi,

Thanks for that.  What event works with this?  I have tried a few things that don't work, and I can use map.infoWindow.hide() to hide the window a split second after it appears, but not to stop it appearing in the first place.  Can you please post the code?

Thanks.


could be in  dojo.connect(map, "onClick", function(evt){ map.infoWindow.hide();.... }); or  dojo.connect(yourfeaturelayer, "onClick", function(evt){ map.infoWindow.hide();.... }); depending upon your code logic..
0 Kudos
MarkSmith
Occasional Contributor
Hi,

These don't work.  I have tried both.  The problem is the hide(), it is not a 'stop', so the infoWindow still shows, so in the case of the event ideas you suggest I expect the hide() actually fires before the show, or I can put some logic in my code to hide() a split second after the show, but the infoWindow still shows for a split second.  I think I need to disable the infoWindow by some other technique but I don't know what.  With the Identify code you actually code the infoWindow.show() to open the infoWindow at the appropriate time, but that seems to be hidden with the editor.

Mark.
0 Kudos
HemingZhu
Frequent Contributor
Hi,

These don't work.  I have tried both.  The problem is the hide(), it is not a 'stop', so the infoWindow still shows, so in the case of the event ideas you suggest I expect the hide() actually fires before the show, or I can put some logic in my code to hide() a split second after the show, but the infoWindow still shows for a split second.  I think I need to disable the infoWindow by some other technique but I don't know what.  With the Identify code you actually code the infoWindow.show() to open the infoWindow at the appropriate time, but that seems to be hidden with the editor.

Mark.


Then you might want to set map's showInfoWindowOnClick as false as default and only show it when necessary. like this
map = new esri.Map("map", {
   ......,
   showInfoWindowOnClick:false
});
0 Kudos
MarkSmith
Occasional Contributor
Hi,

No, that doesn't work either, I have:
map = new esri.Map("mapDIV", { extent: customExtent, showInfoWindowOnClick:false });

And the infoWindow still appears when editing, the above probably only applies to the Identify.  Any chance you feel like trying it to make sure it's not just me?

Thanks.
0 Kudos
HemingZhu
Frequent Contributor
Hi,

No, that doesn't work either, I have:
map = new esri.Map("mapDIV", { extent: customExtent, showInfoWindowOnClick:false });

And the infoWindow still appears when editing, the above probably only applies to the Identify.  Any chance you feel like trying it to make sure it's not just me?

Thanks.


Well i looked at the API carefully. It stated showInfoWindowOnClick:false only works "if the Graphic has a defined InfoTemplate when the user clicks on the graphic". I tested it. showInfoWindowOnClick:false indeed worked on a layer (feature or graphiclayer) which has a defined infoTemplate. It did not honored if the layer has no infoTemplate attached. You might have to define a infoTemplate so you can workround it. Good luck.
0 Kudos
MarkSmith
Occasional Contributor
Hi,
I appreciate all your responses, but I'm still getting nowhere.  I have tried defining an infoTemplate, but the infoWindow that appears when I click a shape for editing is just the default template, for some reason I don't seem to be able to alter it.  Below is my code that runs to load the editor service if that gives any clues.  I haven't used the infoTemplate before so I could be getting it wrong.  Also, I still have the code in place which should stop the window appearing anyway, and that's not taking effect.  If you have any working code you don't mind sharing then please post it.  Thank you.

function loadEditor() {
    infoTemplate = new esri.InfoTemplate();
    infoTemplate.setContent("<b>Reference: </b>${APP_REF}");
    
    planAppsLayer = new esri.layers.FeatureLayer("http://myServer/ArcGIS/rest/services/Test/myService/FeatureServer/0", {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        infoTemplate: infoTemplate,
        outFields: ["*"]
    });
    dojo.connect(map, "onLayersAddResult", initEditing);
    map.addLayers([planAppsLayer])
}
0 Kudos
HemingZhu
Frequent Contributor
Hi,
I appreciate all your responses, but I'm still getting nowhere.  I have tried defining an infoTemplate, but the infoWindow that appears when I click a shape for editing is just the default template, for some reason I don't seem to be able to alter it.  Below is my code that runs to load the editor service if that gives any clues.  I haven't used the infoTemplate before so I could be getting it wrong.  Also, I still have the code in place which should stop the window appearing anyway, and that's not taking effect.  If you have any working code you don't mind sharing then please post it.  Thank you.

function loadEditor() {
    infoTemplate = new esri.InfoTemplate();
    infoTemplate.setContent("<b>Reference: </b>${APP_REF}");
    
    planAppsLayer = new esri.layers.FeatureLayer("http://myServer/ArcGIS/rest/services/Test/myService/FeatureServer/0", {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        infoTemplate: infoTemplate,
        outFields: ["*"]
    });
    dojo.connect(map, "onLayersAddResult", initEditing);
    map.addLayers([planAppsLayer])
}


It could not be any better than just use the ESIR sample: I picked up the following one. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/fl_selectfeatures.html.
Just add showInfoWindowOnClick: false in sample's statement: var map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(initialExtent), slider: true, nav: true }); Watch the behaviors with and without showInfoWindowOnClick: false. You can see it clearly take effect on the behavior of infowindow.
0 Kudos