davidrenz

Select Feature by ID

Discussion created by davidrenz on Apr 21, 2011
Latest reply on Apr 21, 2011 by davidrenz
i am trying to select a feature on a featureLayer by the IDNUM.  it looks like the selection is happening, but the selection is not showing up on the map. can anyone tell me what might be going on here?

thanks
david


       
function Init() {
            
            $.ajax(
                {
                    url: "<%=System.Web.HttpContext.Current.Request.ApplicationPath.ToString() %>/Projects/GetProjectDates",
                    cache: false,
                    success: function (data) {
                        loadConstructionDates(data.ProjectDataTable);
                    }
                }
             );

            var iniExtent = new esri.geometry.Extent({"xmin": 4249987, "ymin": 238755, "xmax": 4315098, "ymax": 274866, "spatialReference":{"wkid":2270}});
   
            map = new esri.Map("map", { extent:iniExtent,logo: false});
            map.enableScrollWheelZoom();

            var layer = new esri.layers.ArcGISTiledMapServiceLayer(BaseMap);
            map.addLayer(layer);

            var streets = new esri.layers.ArcGISTiledMapServiceLayer(TransportationMap);
            map.addLayer(streets);

            featureLayer = new esri.layers.FeatureLayer(FeatureMap, {
                outFields: ["*"],
                mode: esri.layers.FeatureLayer.MODE_SELECTION,
                id: "streetsFeatureLayer"
            });

            var fieldsSelectionSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 255, 255, 0.95]), 2);
            featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
            
            map.addLayer(featureLayer);
            
            dojo.connect(featureLayer, "onSelectionComplete", selectionComplete);
 }
 
 function loadConstructionDates(constructionDates)
 {
     m_constructionProjectDates = constructionDates;
 
     if (m_constructionProjectDates.length > 0) {
      showConstructionProjects();
     }
 }
 
 
        function showConstructionProjects() {
            var streetIDs = "";
            
            for (p in m_constructionProjectDates) {
                var project = m_constructionProjectDates[p];

                if (project.StreetIDNUM.length > 0) {
                    
                    var id = project.StreetIDNUM;
                    var query = new esri.tasks.Query();
                    query.where = "IDNUM = " + id;
                    featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);  
                }
            }
        }
       
        function selectionComplete()
        {
            console.log("This one is done");
        }

Outcomes