arcgis for silverlight 多矿监控项目一工程搭建

开发环境:

vs2010 sp1

silverlight 4

Arcgis for silverlight Api V2.2

arcgis server 9.3

安装开发环境到baidu上面找,一大把!如我能帮忙的,请留言!

看下项目结果,我的做法很简单!如图:

silverlight 项目引用esri.Arcgis .Client程序集。

web就是一asp.net应用程序,里面写了一个wcf服务,主要用于读取数据的。由于是公司项目,从数据库读取数据这块我讲生了。直接返回一些固定的数据给客户端!请谅解!

发布地图,首先要发布多矿监控的地图,如何发布地图也直接上baidu找,教程很多,我就不多讲了。或者可以直接使用esri官方的地图地址;

http://help.arcgis.com/en/webapi/silverlight/supportfiles/header_SAMPLES.html 这有很多的列子,看xaml就可以找到地图的rest地址;

1.显示地图:

 <esri:Map x:Name="monitorMap">
<esri:ArcGISTiledMapServiceLayer Url="http://192.168.8.188/ArcGIS/rest/services/kjtxnetMain/MapServer"></esri:ArcGISTiledMapServiceLayer>

地图服务:kjtxnetMain 是切片地图服务,如果发布切片地图。如果需要我会专门写一篇!

加入上面的代码就会显示地图,看看运行的效果!

放大、缩小、平移等操作map控件多已经实现了。体验效果比adf的爽多了!下一步咱们要加入一个地图下载的进度条;目的也是增加用户体验效果!

 <!--下载进度条-->
<Grid x:Name="grdProbar" Width="200" Height="20" Visibility="Collapsed">
<ProgressBar x:Name="progress"/>
<TextBlock x:Name="txtprogress" Text="正在加载0%" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Grid>

使用的就是一个ProgressBar +TextBlock  Map控件有一个 Progress 事件,实际就是一个地图下载进度事件;MainPage.xaml代码:

<UserControl xmlns:esri="http://schemas.esri.com/arcgis/client/2009"  x:Class="MapMonitor.MainPage"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
="d"
d:DesignHeight
="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="monitorMap" Progress="monitorMap_Progress">
<esri:ArcGISTiledMapServiceLayer Url="http://192.168.8.188/ArcGIS/rest/services/kjtxnetMain/MapServer"></esri:ArcGISTiledMapServiceLayer>
</esri:Map>
<!--下载进度条-->
<Grid x:Name="grdProbar" Width="200" Height="20" Visibility="Collapsed">
<ProgressBar x:Name="progress"/>
<TextBlock x:Name="txtprogress" Text="正在加载0%" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Grid>
</Grid>
</UserControl>

cs代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MapMonitor
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();

}

private void monitorMap_Progress(object sender, ESRI.ArcGIS.Client.ProgressEventArgs e)
{

if (e.Progress < 100)
{
progress.Value = e.Progress;
txtprogress.Text = string.Format("已经完成{0}%", e.Progress);
grdProbar.Visibility = System.Windows.Visibility.Visible;
}
else
{
grdProbar.Visibility = System.Windows.Visibility.Collapsed;
}


}
}
}

ok!要改其他项目的bug去了。欢迎大家一起讨论!下次讨论平移、放大、缩小、全屏等功能实现。


代码下载

posted @ 2011-10-11 18:00  _hqh  阅读(2613)  评论(7编辑  收藏  举报