1. There is query parameter query.objectIds = [12345,23456]; that takes a simple array of objectIds, I assume it is semi-efficient. You could then add as graphics to map. See code below...2. You may want to check out using a FeatureLayer service using MODE_SELECTION and then selectFeatures(query, selectionMethod?)
var aObjectIds = [];
aObjectIds.push(12345);
aObjectIds.push(67890);
detailQueryTask = new esri.tasks.QueryTask(mapServiceName);
detailQuery = new esri.tasks.Query();
detailQuery.objectIds = aObjectIds;
detailQuery.returnGeometry = true;
detailQuery.outFields = ["*"];
detailQueryTask.execute(detailQuery, function (results) {
doSomething(results);
if (results.features !== undefined && results.features.length !== 0) {
zoomToPointFeaturesExtent(results);
highlightMonuments(results, "STYLE_SQUARE");
}
function zoomToPointFeaturesExtent(results) {
var xtent,
xmin = results.features[0].geometry.x,
ymin = results.features[0].geometry.y,
xmax = results.features[0].geometry.x,
ymax = results.features[0].geometry.y;
dojo.forEach(results.features, function (feature) {
if (feature.geometry.x > xmax) { xmax = feature.geometry.x; }
if (feature.geometry.y > ymax) { ymax = feature.geometry.y; }
if (feature.geometry.x < xmin) { xmin = feature.geometry.x; }
if (feature.geometry.y < ymin) { ymin = feature.geometry.y; }
});
xtent = new esri.geometry.Extent(xmin, ymin, xmax, ymax, map.spatialReference);
map.setExtent(xtent, true);
}
function highlightMonuments(results, markerType) {
map.graphics.clear();
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 255, 255, 1.0]), 3));
symbol.setStyle(esri.symbol.SimpleMarkerSymbol[markerType]);
symbol.setColor(new dojo.Color([0, 255, 255, 0.0])); // hollow center, fully transparent
symbol.setSize(10);
var geom;
dojo.forEach(results.features, function (value) {
geom = value.geometry;
var graphic = new esri.Graphic(geom, symbol);
map.graphics.add(graphic);
});
}
Show me some love with an answer?