Select to view content in your preferred language

Attribute Inspector doesn't open when editing

1108
2
Jump to solution
09-13-2017 07:37 AM
LindaDunklee
Occasional Contributor

  I am attempting to use the Editor widget from the JS API - my editor initializes and I can see all of the layers/symbols available that I want to be able to edit.  Clicking on one and drawing on the map creates a feature, but the attribute inspector never opens.  Clicking on an already created feature also does not open the attribute inspector.  Code is below.  Not all layers in my application should be editable, so I am looping through a list to add them to the editor widget.  This works fine.  The init edit function is fired when a button is clicked, which opens a panel containing the edit Div.

var editor;
var templatePicker;

require([
"esri/map",
"esri/tasks/GeometryService",
"esri/layers/FeatureLayer",
"esri/Color",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/dijit/editing/Editor",
"esri/dijit/editing/TemplatePicker",
"esri/config",
"dojo/i18n!esri/nls/jsapi",
"dojo/_base/array",
"dojo/parser",
"dojo/keys",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
], function(
Map,
GeometryService,
FeatureLayer,
Color,
SimpleMarkerSymbol,
SimpleLineSymbol,
Editor,
TemplatePicker,
esriConfig,
jsapiBundle,
arrayUtils,
parser,
keys
) {


// snapping is enabled for this sample - change the tooltip to reflect this
jsapiBundle.toolbars.draw.start = jsapiBundle.toolbars.draw.start + "<br>Press <b>ALT</b> to enable snapping";

// refer to "Using the Proxy Page" for more information: https://developers.arcgis.com/javascript/3/jshelp/ags_proxy.html
//esriConfig.defaults.io.proxyUrl = "/proxy/";

//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.
esriConfig.defaults.geometryService = new GeometryService(geometryService);

initEditor = function(evt) {
document.getElementById("pnlEdit").style.height = spatialEditSize;
var templateLayers = [];
var lay = [];
for (i=0;i<layers.length;i++){
if (layers.spatialEdit == true){
templateLayers.push(layerList);
lay.push({featureLayer: layerList})
}
}

templatePicker = new TemplatePicker({
featureLayers: templateLayers,
grouping: true,
rows: "auto",
columns: 3,
}, "templateDiv");
templatePicker.startup();

var settings = {
map: map,
templatePicker: templatePicker,
layerInfos: lay,
toolbarVisible: true,
createOptions: {
polylineDrawTools:[ Editor.CREATE_TOOL_FREEHAND_POLYLINE ],
polygonDrawTools: [ Editor.CREATE_TOOL_FREEHAND_POLYGON,
Editor.CREATE_TOOL_CIRCLE,
Editor.CREATE_TOOL_TRIANGLE,
Editor.CREATE_TOOL_RECTANGLE
]
},
toolbarOptions: {
reshapeVisible: true
}
};

var parameters = { settings: settings};
console.log(parameters);
editor = new Editor(parameters, 'editorDiv');
//define snapping options
var symbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CROSS,
15,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0, 0.5]),
5
),
null
);
map.enableSnapping({
snapPointSymbol: symbol,
tolerance: 20,
snapKey: keys.ALT
});
editor.startup();
console.log(settings);
}
});

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

There is a note in the constructor section of the TemplatePicker help:

The TemplatePicker must be created and started inside the onLoad event of the map or the layer for which it is associated.

You aren't doing that in your code.

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

There is a note in the constructor section of the TemplatePicker help:

The TemplatePicker must be created and started inside the onLoad event of the map or the layer for which it is associated.

You aren't doing that in your code.

LindaDunklee
Occasional Contributor

Thanks a ton Ken!

0 Kudos