查询 查询任务 Silverlight 与 ESRI 地图

发布于 2024-09-13 03:10:31 字数 57 浏览 5 评论 0原文

我在哪里可以学习如何查询 ESRI 地图的图层?我需要查询 esri 地图图层并将数据存储在字典中。

Where can i learn how to query the layers of an ESRI Map? I need to query the layer of esri maps and store the data in dictionary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦巷 2024-09-20 03:10:31

ESRI Silverlight SDK 为此提供了一个QueryTask 对象。您的地图必须通过 ArcGIS Server 来发布,并提供用于查询的 REST 端点 (URL)。查看 ESRI 示例页面 。它们包括不同查询风格的几个示例。

在最简单的形式中,查询将类似于...

void DoQuery()
{
    QueryTask queryTask = new QueryTask("[AGS Service Endpoint]"); // Service url typically in format of http://[servername]/ArcGIS/rest/services/[ServiceName]/MapServer/[LayerId]
    queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;

    ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
    query.Where = "1=1"; // Return all features
    query.OutFields.Add("*"); // Return all fields
    queryTask.ExecuteAsync(query);
}

void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
    FeatureSet featureSet = args.FeatureSet;

    if (featureSet == null || featureSet.Features.Count == 0) return;

    foreach (Graphic feature in featureSet.Features)
    {
        // feature.Attributes is a type Dictionary<string, object> containing all attributes. Do something with it.
    }
}

The ESRI Silverlight SDK provides a QueryTask object for this. Your map must be published with ArcGIS Server providing a REST endpoint (URL) to query against. Check out the ESRI sample page. They include several examples of different styles of queries.

In its simplest form, a query will look like...

void DoQuery()
{
    QueryTask queryTask = new QueryTask("[AGS Service Endpoint]"); // Service url typically in format of http://[servername]/ArcGIS/rest/services/[ServiceName]/MapServer/[LayerId]
    queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;

    ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
    query.Where = "1=1"; // Return all features
    query.OutFields.Add("*"); // Return all fields
    queryTask.ExecuteAsync(query);
}

void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
    FeatureSet featureSet = args.FeatureSet;

    if (featureSet == null || featureSet.Features.Count == 0) return;

    foreach (Graphic feature in featureSet.Features)
    {
        // feature.Attributes is a type Dictionary<string, object> containing all attributes. Do something with it.
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文