当前位置:Gxlcms > JavaScript > 教你如何使用arcgis执行查询任务

教你如何使用arcgis执行查询任务

时间:2021-07-01 10:21:17 帮助过:298人阅读

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

url = string.Format("http://{0}/arcgis2/rest/services/baidu/MapServer/{1}", ip, layerID);
                QueryTask queryTask = new QueryTask(url);
                queryTask.ExecuteCompleted += new EventHandler<QueryEventArgs>(queryTask_ExecuteCompleted);
                queryTask.Failed += new EventHandler<TaskFailedEventArgs>(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);
            }
        }

相关推荐:

Win7,Win8安装ArcGIS软件或Node.js等安装包出现2503错误的解决_MySQL

基于Arcgis for javascript实现百度地图ABCD marker的效果_javascript技巧

以上就是教你如何使用arcgis 执行查询任务的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行