Select to view content in your preferred language

Query data present in xml

756
1
08-13-2012 06:35 AM
PramodHarithsa1
Frequent Contributor
I have list of ObjectId's present in xml
want to highlight them on map by adding a graphic layer.
How do i write a query to search this?
I had a wiered idea of doing this
foreach(oid in xml)
{
query.where="OBJECTID="+oid+" or ";
}
xml generally contains 1000 values [confused/]
var query = new esri.tasks.Query();
            query.returnGeometry = true;
            query.outFields = ["OBJECTID", "CMDTY", "DIA_IN", "RISK_SCORE", "MOD_DATE"];
            query.outSpatialReference = { "wkid": 102100 };
            query.where = "";   //How do i do this??
            var infoTemplate = new esri.InfoTemplate();
            infoTemplate.setTitle("${OBJECTID}");
            infoTemplate.setContent("<b>Comodity: </b>${CMDTY}<br/>"
                             + "<b>Internal Diameter: </b>${DIA_IN}<br/>"
                             + "<b>Risk Score: </b>${RISK_SCORE}<br/>"
                             + "<b>Last Updated on: </b>${MOD_DATE}");

            map.infoWindow.resize(245, 125);


            dojo.connect(queryTask, "onComplete", function (featureSet) {
            map.graphics.clear();
var highlightSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([0, 0, 0]), 3);
var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 1);
var countiesGraphicsLayer = new esri.layers.GraphicsLayer();
                   for (var i = 0, il = featureSet.features.length; i < il; i++) {
                    var graphic = featureSet.features;
                    graphic.setSymbol(symbol);
                    graphic.setInfoTemplate(infoTemplate);

                    countiesGraphicsLayer.add(graphic);
                }
                map.addLayer(countiesGraphicsLayer);
                map.graphics.enableMouseEvents();
0 Kudos
1 Reply
JeffPace
MVP Alum
it would be much more efficient to write your objectid's to a string

(1,2,3,5,) etc..
and set the where clause to be

where OBJECTID in (1,2,3,5,)
0 Kudos