I'm attempting to replace the editor widget with my own code to get greater control of the infotemplate. When I create a new feature using the template picker I then want to show an info window with the attributes of that feature class. However, I'm running into problems:If I use the 'onDrawEnd' event with the following code, the info window does not show the attributes. It simply shows the literal infoTemplate string: '{*}'.
dojo.connect(drawToolbar, "onDrawEnd", function(geometry) {
drawToolbar.deactivate();
editToolbar.deactivate();
var newAttributes = dojo.mixin({},selectedTemplate.template.prototype.attributes);
selectedTemplate.featureLayer.applyEdits([newGraphic], null, null);
var infoTemplateInst = new esri.InfoTemplate("Attributes", "${*}");
newGraphic.setInfoTemplate(infoTemplateInst);
map.infoWindow.show(map.toScreen(newGraphic.geometry), map.getInfoWindowAnchor(map.toScreen(newGraphic.geometry)));
});
If I use the 'onBeforeApplyEdits' event with the following code, info window does not show or is initially blank.
dojo.connect(featureLayers,"onBeforeApplyEdits", function(adds,updates,deletes) {
dojo.forEach(adds, function(add) {
var infoTemplateInst = new esri.InfoTemplate("Attributes", "${*}");
add.setInfoTemplate(infoTemplateInst);
map.infoWindow.show(map.toScreen(add.geometry), map.getInfoWindowAnchor(map.toScreen(add.geometry)));
});
});
If I use the 'onClick' even with the following code it does work but it is initially blank. After I click again on the new feature, the info window displays correctly and continues to for subsequently created features.
dojo.connect(featureLayers, 'onClick', function(e) {
var infoTemplateInst = new esri.InfoTemplate("Attributes", "${*}");
e.graphic.setInfoTemplate(infoTemplateInst);
map.infoWindow.show(map.toScreen(e.graphic.geometry), map.getInfoWindowAnchor(map.toScreen(e.graphic.geometry)));
});
Has someone got an example of creating a new feature and then displaying an info window with the feature's attributes?
Regards,
Mark