I have trouble about selecting the feature layer based on its attribute. I got this code below but it says:
Uncaught TypeError: Cannot read property 'features' of undefined
here's my code:
 var init = function () { // A function that will initialize and execute all the declared variables
    var geographic = new OpenLayers.Projection("EPSG:4326"); // Setting the standard geographic projection
    var mercator = new OpenLayers.Projection("EPSG:3857"); // Setting the universal geographic projection
    map = new OpenLayers.Map('map'); // Creating & initializing map constructor
    var base_osm = new OpenLayers.Layer.OSM("OpenStreetMap"); // Setting OpenStreetMap as a BaseMap
    map.addControl(
            new OpenLayers.Control.MousePosition({
                prefix: '<small style="color:blue">',
                suffix: '</small>',
                numDigits: 2,
                emptyString: '<small style="color:red">' + 'Mouse is not over map.' +'</small>'
            })
    );
    var layer_agao = new OpenLayers.Layer.Vector("Agao");
    map.addLayers([layer_agao, base_osm]); // Adding the vector layer to the map
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    selectControl = new OpenLayers.Control.SelectFeature(layer_agao, {
         onSelect: onFeatureSelect, onUnselect: onFeatureUnselect
    });
    map.addControl(selectControl);
    selectControl.activate();
    map.setCenter(new OpenLayers.LonLat(13975400.3513, 999830.692078),16);
    var format_agao = new OpenLayers.Format.GeoJSON(); //initializing and calling the rendered GeoJSON Layer from views.py
    var feat_agao = format_agao.read({{agao_transform|safe}});
    layer_agao.addFeatures(feat_agao);
    layer_agao.events.on({
            featureselected: function(event) {
                 var feature = event.feature;
                 var area = feature.geometry.getArea();
                 var id = feature.attributes.newpin;
                 var output = "Land Pin: " + id + "<br/>" + "Area: " + area.toFixed(12);
                    document.getElementById("status").innerHTML = output;
            }
    });
init.showparcel();
}
init.showparcel = function (getpin){
            for(var f=0;f<layer_agao.features.length;f++) {
                if(layer_agao.features[f].attributes.newpin == getpin) {
                    selectControl.select(layer_agao.features[f]);
                    break;
                }
            }
}
I also read about  getfeaturesbyattribute, but i can't find any example. So, is there other way to call the specific feature layer on click (event)? This is for my searching...
 
     
    