Feature Layer Select query problem

2463
1
04-08-2015 03:27 AM
NadirHussain
Occasional Contributor II

var myFeatureLayer = new FeatureLayer("http://dell-pc/ArcGIS/rest/services/SirenFeatureService/FeatureServer/1", {

          mode: FeatureLayer.MODE_SELECTION,

          outFields: ["SIREN_NO", "Reg_E", "Reg_A", "Featuer_Type", "Description", "Location", "POINT_X"]

            });

map.on("click", function(evt) {

            try

            {

            selectQuery.geometry  =evt.mapPoint;

           myFeatureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function(features) {

               if (features.length > 0) {

                //store the current feature

                updateFeature = features[0];

                map.infoWindow.setTitle(features[0].getLayer().name);

                map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));

              }

              else {

                map.infoWindow.hide();

              }

            });

            }//try

           

            catch (err) {

                     txt = "There was an error on this page.\n\n";

                     txt += "Error description: " + err.message + "\n\n";

                     txt += "Click OK to continue.\n\n";

                     alert(txt);

                 }

           

          });

in above code featurelayer 1 is point layer and its symbols are picturemarker symbol in symbology.if i click on this symbol feature return 0.Even i check it returns the x and y point..if i change the feature layer number like 3,which is my polygon layer.it is simplefillsymbol in symbology.when i click on this it give me the feature.what can be the reason.might be the line is any  selectQuery.geometry  =evt.mapPoint is any problem.this works for polgon layer not work for point layer.

please help.

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

Nadir,

  I use this function to change the point into a extent so that point selection works.

pointToExtent: function(objPoint, distance){
  var clickOffset = distance || 6;
  var centerPoint = new Point(objPoint.x,objPoint.y,objPoint.spatialReference);
  var mapWidth = map.extent.getWidth();
  var pixelWidth = mapWidth/map.width;
  var tolerance = clickOffset * pixelWidth;
  var queryExtent = new Extent(1,1,tolerance,tolerance,objPoint.spatialReference);
  return queryExtent.centerAt(centerPoint);
},
0 Kudos