首頁 >web前端 >js教程 >教你如何使用arcgis 執行查詢任務

教你如何使用arcgis 執行查詢任務

坏嘻嘻
坏嘻嘻原創
2018-09-14 11:01:072558瀏覽

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 執行查詢任務的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn