The first error points to line 47
layer.queryFeatures(query, lang.hitch(this, function(featureSet) {
which means that "layer" is undefined. You get that earlier at line 39
var layer = this.map.getLayer(this.config.layerId);
Have you set the layerId property in the config to a valid layer in the map?