通常我们在对服务查询到结果集后,需要把视域定位到结果集上,这时可以使用到 graphicsUtils来实现
var queryTask = new esri.tasks.QueryTask(
"http://localhost:6080/arcgis/rest/services/gzhb/FeatureServer/0");var query = new esri.tasks.Query();
query.returnGeometry = true;
query.objectIds = ids;
query.outFields = [ "*" ];
queryTask.execute(query, showResults);
function showResults(results) {
var myFeatureExtent =esri.graphicsUtils.graphicsExtent(results.features);//根据结果集,获取范围
map.setExtent(myFeatureExtent.expand(2)); //定位到查询的区域,如果范围不合适可以使用myFeatureExtent.expand(2)扩大倍数
}
如有疑问,请联系:
QQ:592566207
E-Mail:jxdnsong@foxmail.com