WebGIS作业
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
WebGIS课程设计作业
姓名:甄真
班级:2011010班
专业:地理信息系统
指导老师:张俊峰许德合
实验步骤:
1.代码实现:
using System;
using System.Collections.Generic;
using System.Linq;
using ;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Markup;
using System.Windows.Shapes;
using ponentModel;
using ESRI.ArcGIS.Client;
using System.Windows.Controls.Primitives;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client.Symbols;
using ESRI.ArcGIS.Client.Behaviors;
using ESRI.ArcGIS.Client.Geometry;
namespace ESRIStandardMapApplication1
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
属性查询:
#region//属º?性?查¨¥询¡¤
private void QueryButton_Click(object sender, RoutedEventArgs e) {
QueryTask queryTask = new
QueryTask("http://zhen-pc/ArcGIS/rest/services/test/MapServer/0");
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query(); query.Text = StateNameTextBox.Text;
query.OutFields.Add("*");
queryTask.ExecuteAsync(query);
}
void QueryTask_ExecuteCompleted(object sender,
ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)//在¨²查¨¥询¡¤完ª¨º成¨¥后¨®触䣤发
¤¡é的Ì?事º?件t
{
FeatureSet featureSet = args.FeatureSet;
if (featureSet != null && featureSet.Features.Count > 0)
{
List
foreach (Graphic feature in featureSet.Features)
{
resultList.Add(new QueryResultData()
{
Id = feature.Attributes["Id"].ToString(),
FID = feature.Attributes["FID"].ToString(),
Area = feature.Attributes["Area"].ToString(),
Name = feature.Attributes["Name"].ToString(),
}
);
}
QueryDetailsDataGrid.ItemsSource = resultList;
}
else
{
MessageBox.Show("No features returned from query");
}
}
private void QueryTask_Failed(object sender, TaskFailedEventArgs args)//在¨²查¨¥询¡¤失º¡ì败㨹
{
MessageBox.Show("Query execute error: " + args.Error);
}
public class QueryResultData
{
public string Id { get; set; }
public string FID { get; set; }
public string Area { get; set; }
public string Name { get; set; }
}
#endregion
书签管理:
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e) {
e.Graphic.Selected = !e.Graphic.Selected;
e.Graphic.Selected = true;
//获?取¨?选?择?要©a素?
if (e.Graphic.Selected == true)
{
//控?件t数ºy据Y源¡ä绑㨮定¡§
//IdentifyDetailsDataGrid.ItemsSource = e.Graphic.Attributes;
}
//将?该?要©a素?平?移©?至¨¢屏¨¢幕?中D心?
Map.PanTo(e.Graphic.Geometry);
}
打开属性表:
#region //属º?性?表À¨ª
private void btnAttributeMenu_Click(object sender, RoutedEventArgs e)
{
string url = "http://zhen-pc/ArcGIS/rest/services/test/MapServer/0";
QueryTask queryTask = new QueryTask(url);
queryTask.ExecuteCompleted += TableQueryTask_ExecuteCompleted;
queryTask.Failed += TableQueryTask_Failed;
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query(); query.Where = "1=1";
query.OutFields.Add("*");
queryTask.ExecuteAsync(query);
}
void TableQueryTask_ExecuteCompleted(object sender,
ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
FeatureSet featureSet = args.FeatureSet;