arcgis server 9.2代码阅读笔记一:在图层中增加一个点
2011-06-23 18:10
405 查看
代码来源 ARCGIS 9.2例子
// Copyright 2006 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// AUTHER:糊涂虫 2007.9.19
// See use restrictions at /arcgis/developerkit/userestrictions.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.ArcGISServer;
using ESRI.ArcGIS.Server;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;
using System.Collections;
using ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer;
public class PointTool : IMapServerToolAction
{
public void ServerAction(ToolEventArgs args)
{
//获得图层控制
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl;
mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map) args.Control;
//获得屏幕上点的集合
PointEventArgs pea = (PointEventArgs)args;
System.Drawing.Point screen_point = pea.ScreenPoint;
//获得图层的能力
MapFunctionality mf = (MapFunctionality) mapctrl.GetFunctionality(0);
//获得图层的描述
ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription = mf.MapDescription;
//把屏幕上的点转换为ADF点
ESRI.ArcGIS.ADF.Web.Geometry.Point adf_map_point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height);
//定义点对象
PointN ags_map_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_map_point);
//设置点的颜色
ESRI.ArcGIS.ADF.ArcGISServer.RgbColor rgb = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
rgb.Red = 0;
rgb.Green = 255;
rgb.Blue = 0;
rgb.AlphaValue = 255;
//设置点的标识符
ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol sms = new ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol();
sms.Style = ESRI.ArcGIS.ADF.ArcGISServer.esriSimpleMarkerStyle.esriSMSDiamond;
sms.Color = rgb;
sms.Size = 20.0;
//设置点
ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement marker = new ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement();
marker.Symbol = sms;
marker.Point = ags_map_point;
if (mapDescription.CustomGraphics != null)
{
//获得该图层上的所有对象
GraphicElement[] oldges = mapDescription.CustomGraphics;
//对象的个数
int cnt = oldges.Length;
//对象个数加一,并把新的对象(点)放进去
GraphicElement[] newges = new GraphicElement[cnt + 1];
oldges.CopyTo(newges, 0);
newges[cnt] = marker;
mapDescription.CustomGraphics = newges;
}
else
{
GraphicElement[] ges = new GraphicElement[1];
ges[0] = marker;
mapDescription.CustomGraphics = ges;
}
mapctrl.Refresh();
}
}
这是一个在图层中添加点的例子,添加线段 图形和文字的代码基本上和这差不错,
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhangjie_xiaoke/archive/2008/03/05/2150725.aspx
// Copyright 2006 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// AUTHER:糊涂虫 2007.9.19
// See use restrictions at /arcgis/developerkit/userestrictions.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.ArcGISServer;
using ESRI.ArcGIS.Server;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;
using System.Collections;
using ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer;
public class PointTool : IMapServerToolAction
{
public void ServerAction(ToolEventArgs args)
{
//获得图层控制
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl;
mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map) args.Control;
//获得屏幕上点的集合
PointEventArgs pea = (PointEventArgs)args;
System.Drawing.Point screen_point = pea.ScreenPoint;
//获得图层的能力
MapFunctionality mf = (MapFunctionality) mapctrl.GetFunctionality(0);
//获得图层的描述
ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription = mf.MapDescription;
//把屏幕上的点转换为ADF点
ESRI.ArcGIS.ADF.Web.Geometry.Point adf_map_point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height);
//定义点对象
PointN ags_map_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_map_point);
//设置点的颜色
ESRI.ArcGIS.ADF.ArcGISServer.RgbColor rgb = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
rgb.Red = 0;
rgb.Green = 255;
rgb.Blue = 0;
rgb.AlphaValue = 255;
//设置点的标识符
ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol sms = new ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol();
sms.Style = ESRI.ArcGIS.ADF.ArcGISServer.esriSimpleMarkerStyle.esriSMSDiamond;
sms.Color = rgb;
sms.Size = 20.0;
//设置点
ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement marker = new ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement();
marker.Symbol = sms;
marker.Point = ags_map_point;
if (mapDescription.CustomGraphics != null)
{
//获得该图层上的所有对象
GraphicElement[] oldges = mapDescription.CustomGraphics;
//对象的个数
int cnt = oldges.Length;
//对象个数加一,并把新的对象(点)放进去
GraphicElement[] newges = new GraphicElement[cnt + 1];
oldges.CopyTo(newges, 0);
newges[cnt] = marker;
mapDescription.CustomGraphics = newges;
}
else
{
GraphicElement[] ges = new GraphicElement[1];
ges[0] = marker;
mapDescription.CustomGraphics = ges;
}
mapctrl.Refresh();
}
}
这是一个在图层中添加点的例子,添加线段 图形和文字的代码基本上和这差不错,
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhangjie_xiaoke/archive/2008/03/05/2150725.aspx
相关文章推荐
- arcgis server 9.2代码阅读笔记一:在图层中增加一个点
- arcgis server 9.2代码阅读笔记一:在图层中增加一个点
- arcgis server 9.2代码阅读笔记二:在页面上动态加载图层
- arcgis server 9.2代码阅读笔记二:在页面上动态加载图层
- arcgis server 9.2代码阅读笔记二:在页面上动态加载图层
- arcgis server 9.2代码阅读笔记二:在页面上动态加载图层
- 在ARCGIS SERVER 9.2中动态增加图层(附代码)
- 在ARCGIS SERVER 9.2中动态增加图层(附代码)
- 一个利用信号捕获实现循环定时器代码阅读笔记
- onvif学习笔记7:一个C++封装的onvif代码的阅读笔记
- 阅读笔记:如何给OpenSolaris增加一个系统调用
- MonitorServer代码阅读笔记(一):使用sigaction( SIGPIPE, &sa, 0)避免写一个已关闭的socket导致进程退出
- 分享过滤条件中增加一个自定义过滤变量插件代码
- Typecho 代码阅读笔记(一) - 页面渲染及路由机制
- 梦断代码阅读笔记02
- nrf51822代码阅读笔记三
- <<梦断代码>>阅读笔记二
- Discuz!NT 代码阅读笔记(9)--DNT数据库中唯一的用户函数解析
- 论文and代码 阅读笔记
- 视频编码SVC --- JSVM代码阅读笔记(五)