Home > Web Front-end > JS Tutorial > Teach you how to use arcgis to perform query tasks

Teach you how to use arcgis to perform query tasks

坏嘻嘻
Release: 2018-09-14 11:01:07
Original
2568 people have browsed it

arcgis Execute query task (QueryTask) and ExecuteAsync? Need to know more about

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);
            }
        }
Copy after login

Related recommendations:

Solution to 2503 error when installing ArcGIS software or Node.js and other installation packages on Win7 and Win8_MySQL

Based on Arcgis for javascript to achieve the effect of Baidu map ABCD marker_javascript skills

The above is the detailed content of Teach you how to use arcgis to perform query tasks. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template