0

How I can programmatically click on feature using javascript library, lets say in world countries map how can I programmatically click on a particular country ( i don't want to use co-ordinate as my does not deal with them).

Country Name comes form rest services. I will highlight the country through querytask i pass countryname in the country i get the feature object then i add symbol object to it and highlight it.

var queryTask = new esri.tasks.QueryTask("http://10.32.9.106:6080/arcgis/rest/services/KX_Mapping/World_countries_less_Antartica/MapServer/0");
var query = new esri.tasks.Query();
query.where="CNTRY_NAME IN ('Some')";
    queryTask.execute(query);
dojo.connect(queryTask, "onComplete", function(featureSet) {
                 try{
                        console.log(" query complete");
                        var symbol0 = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.9]));
                        dojo.forEach(featureSet.features,function(feature){
                                //alert('feature'+feature);
                                var graphic = feature;
                                graphic.setSymbol(symbol0);
                                //alert("infoTemplate"+infoTemplate);
                                var infoTemplate = new esri.InfoTemplate("Alert", "ds");
                                graphic.setInfoTemplate(infoTemplate);
                                //alert("graphic"+graphic);
                                //alert("map.graphics"+map.graphics);
                                map.graphics.add(graphic);
                        });
                    }catch(e){
                        alert("e"+e);
                    }
                });

I have associated infotemplate object to graphic object , template will be shown when user click on that country , how can i programitically make it clickable.

closed as unclear what you're asking by PolyGeo, Fezter, Get Spatial, MappaGnosis, Jason Scheirer Sep 25 '13 at 22:59

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What do you mean by 'programatticaly click'? What are you trying to achieve? – Devdatta Tengshe Sep 20 '13 at 11:36
  • IN usual scenario uses takes mouses and say clicks on any country but lets say there is link of some country name out of map and when user clicks on country name i have to highlight that country , i.e i have to invoke onclick function of feature layer programitically that too at specific point – Anil Sep 20 '13 at 12:40
  • where is the country name? inside the map or somewhere else? And how will you highlight the country? Do you have the boundaries as a featurelayer? What have you tried so far? You need to provide more information to us. – Devdatta Tengshe Sep 20 '13 at 14:46
  • Country Name comes form rest services. I will highlight the country through querytask i pass countryname in the country i get the feature object i add symbol object to it and highlight it. – Anil Sep 20 '13 at 14:57
  • I tried to call click function to feature(graphic) object returned through query but it fails – Anil Sep 20 '13 at 14:58
2

If you're trying to do something with a particular feature in a layer when the user clicks another layer or something outside the map, there isn't a click function for a feature. Instead, using some value from the user's interaction (say, the country name). Check the selectFeatures function in the API documentation for FeatureLayer.

  • Thanks i am be select feature but To show infotemplate associated with it – Anil Sep 20 '13 at 15:15
  • @Anil - The info window belongs to the map, not to the feature. There's a sample for using the info window with a feature layer in the documentation at developers.arcgis.com/en/javascript/jssamples/fl_popup.html. – Tim Rourke Sep 20 '13 at 15:28
  • problem it takes evt.mapPoint which comes from mouse click but i am doing it programitically – Anil Sep 20 '13 at 15:34
  • 1
    Is the country guaranteed to be showing in the map window? If so, you can find the centroid of the graphic (see developers.arcgis.com/en/javascript/jsapi/…) and replace evt.mapPoint with the centroid. – Tim Rourke Sep 20 '13 at 15:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.