欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

arcgis执行查询任务

程序员文章站 2023-11-24 12:47:46
 arcgis 执行查询任务(querytask)还有executeasync?需进一步了解 string.format("https://{0}/arcgis2/rest/s...

    arcgis 执行查询任务(querytask)还有executeasync?需进一步了解

    string.format("https://{0}/arcgis2/rest/services/baidu/mapserver/{1}", ip, layerid);
    querytask querytask = new querytask(url);
    querytask.executecompleted += new eventhandler(querytask_executecompleted);
    querytask.failed += new eventhandler(querytask_failed);
    esri.arcgis.client.tasks.query query = new esri.arcgis.client.tasks.query();
    query.outfields.add("*");
    query.returngeometry = true;
    query.where = string.format("fid={0}", querytext);
    querytask.executeasync(query);

    private void querytask_failed(object sender, taskfailedeventargs e)
    {
    messagebox.show("query failed: " + e.error);
    }

    private void querytask_executecompleted(object sender, queryeventargs e)
    {
    featureset featureset = e.featureset;
    if (featureset != null && featureset.features.count > 0)
    {
    graphic selectedfeature = featureset.features[0];
    // 放大到选择的要素
    esri.arcgis.client.geometry.envelope selectedfeatureextent = selectedfeature.geometry.extent;
    double expandpercentage = 30;
    double widthexpand = 2000 * (expandpercentage / 100);
    double heightexpand = 2000 * (expandpercentage / 100);
    esri.arcgis.client.geometry.envelope displayextent = new esri.arcgis.client.geometry.envelope(
    selectedfeatureextent.xmin - (widthexpand / 2),
    selectedfeatureextent.ymin - (heightexpand / 2),
    selectedfeatureextent.xmax + (widthexpand / 2),
    selectedfeatureextent.ymax + (heightexpand / 2));
    mymap.zoomduration = new timespan(0, 0, 2);
    mymap.zoomto(displayextent);
    }
    }