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去了。欢迎大家一起讨论!下次讨论平移、放大、缩小、全屏等功能实现。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?