I know there are many threads on editing and navigation, but I still can't figure it out. I want to be able to enable/disable editing on my featureLayer.
I have a boolean set as app.editEnabled.
I have the button constructed as a toggleButton:
createEditButton: function (){
var tglButton = new ToggleButton({
showLabel: true,
label: 'Begin Editing',
onChange: function(val) {
if (val){
this.set('label', 'Stop Editing');
app.editEnabled = true;
}else{
this.set('label', 'Begin Editing');
app.editEnabled = false;
}
}
}, "tglEditButton");
},
It is properly changing my Boolean and my button label.
var template = new PopupTemplate({ title: null });
template.setContent(setPopupContent);
My FeatureLayer is defined as
featureLayer = new FeatureLayer(pathName+"/arcgis/rest/services/MDA/sampleGeocodeEdit/FeatureServer/0",{
id:"featureLayer",
outFields:['*'],
infoTemplate:template
});
//symbology defined elsewhere
featureLayer.renderer = renderer;
featureLayer.setSelectionSymbol(highlightMarkerSymbol);
I have a listener on it:
on(featureLayer, "click", function(evt){
map.infoWindow.hide();
formatString = "";
objectId = evt.graphic.attributes[featureLayer.objectIdField];
selectQuery.objectIds = [objectId];
featureLayer.selectFeatures(selectQuery);
if (app.editEnabled) {
myEditor.activateToolbar(evt.graphic,map);
}
});
in myEditor
activateToolbar: function (graphic,map) {
map.infoWindow.hide();
map.disableMapNavigation();
map.disablePan();
app.editToolbar.activate(Edit.MOVE, graphic);
on(app.editToolbar, 'graphic-move-stop', function(evt){
featureLayer.applyEdits(null, [graphic], null);
app.editToolbar.deactivate();
map.enableMapNavigation();
map.infoWindow.hide();
});
}
There is where I'm getting stuck. Instead of the graphic moving when I drag the mouse, it still just pans the screen instead. As long as my feature doesn't have an infoTemplate, the graphic drags. Once I include one in my featureLayer constructor, navigation is not disabled and instead of dragging the graphic, it just pans. I've tried hiding the infoWindow, but it isn't getting removed.