AnsweredAssumed Answered

Feature Query Selection.

Question asked by Nadir_Hussain on Jan 31, 2016
Latest reply on Feb 1, 2016 by rscheitlin

Dear all

on my page load event i create one circle graphic element.by using below code. in page load event

i add one feature layer.

           map.addLayers([myFeatureLayer]);

           map.on("layers-add-result", drawCircle(evt));

function drawCircle(evt){

               var ptLayer = evt.layers[0].layer;

                var pt = new Point("45.42", "23.24", map.SpatialReference);

                var selectQuery = new Query();

                 circle = new Circle({

                        center: pt,

                        geodesic: true,

                        radius: 500,

                        radiusUnit: "esriMiles"

                    });

                     map.graphics.clear();

                    var graphic = new Graphic(circle, circleSymb);

                    map.graphics.add(graphic);

                    var selectQuery= new Query();

                    selectQuery.geometry = circle.getExtent();

                    selectQuery.distance = 500;

                    selectQuery.units = "miles";

                    selectQuery.returnGeometry = true;

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

                            if (features.length > 0) {

                                 updateFeature = features[0];

                                map.infoWindow.setTitle("Editor");

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

                                map.infoWindow.show(pt, map.getInfoWindowAnchor(pt));

                            

                            }

                            else {

                                map.infoWindow.hide();

                            }

                        });

 

}

 

if i call this function on map click event it return features.But if i call this on page load event.no feature returns.what can be the reason.please help.i have to use this code my production part.

thanks once again.

Outcomes