ARCGIS经典代码
来源:互联网 发布:qq红包钓鱼源码下载 编辑:程序博客网 时间:2024/05/21 11:36
#region 预处理
if (!Page.IsCallback && !Page.IsPostBack)
{
tool = new ArcServerTool(this.Map1);
string querylayer = this.Request.QueryString["layer"];
if (querylayer == null) querylayer = "";
if (querylayer != "")
handLayerTip(querylayer);
string Input = this.Request.QueryString["name"];
if (Input == null) Input = "";
if ((Input == "") && (querylayer == "")) { }
else
{
if ((Input == "") && (querylayer != ""))
{
#region 单层查询
TipLayer(querylayer);
#endregion
}
else
{
if (Input == null) return;
DM2 dm = new DM2();
DataSet ds = dm.getsql("select id from information where fzmc='" + Input + "'");
if (ds.Tables[0].Rows.Count > 0)
skid.InnerHtml = ds.Tables[0].Rows[0][0].ToString();
#region 单点查询
FindSpace(Input);
#endregion
}
}
}
#endregion
}
#region 加入的非系统函数
public ArcServerTool tool;
public void handLayerTip(string querylayer)
{
try
{
string resource = "MapResourceItem0";
string layerID = tool.getLayerID(querylayer, resource);
// Make sure a layer ID was found
if (layerID == null)
return;
ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerFormat layerFormat = ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerFormat.FromMapResourceManager(MapResourceManager1, resource, layerID);
MapTips1.LayerFormat = layerFormat;
string headstr = " 详细";
MapTips1.LayerFormat.Title = querylayer + ":{name}" + headstr;
if (querylayer.Trim() == "江心洲") { MapTips1.LayerFormat.UseDefaultTitleAndContents = true; }
else
{
MapTips1.LayerFormat.Contents = "" +
"" +
"" +
" "color:red;'>";
}
}
catch { }
// MapTips1.Style.Value[]
//if (querylayer == "水位站")
//{
// MapTips1.ClickImage = "images/identify2.png";
// MapTips1.HoverImage = "images/identify2.png";
// MapTips1.DefaultImage = "images/identify.png";
// MapTips1.LayerFormat.Contents = "" +
// "" +
// "" +
// " // "color:red;'>";
// //"";
//}
//else if (querylayer == "河流")
//{
// MapTips1.LayerFormat.Contents = "";
//}
//else if (querylayer == "雨量站")
//{
// MapTips1.ClickImage = "images/yq.png";
// MapTips1.HoverImage = "images/yq.png";
// MapTips1.DefaultImage = "images/yq2.png";
// MapTips1.LayerFormat.Contents = "";
//}
//else if (querylayer == "水库")
//{
// MapTips1.LayerFormat.Contents = "";
//}
}
///
/// 对某个层显示Tip
///
///
private void TipLayer(string querylayer)
{
//设置MapTips1的属性
MapTips1.FeatureLimit = 20;
MapTips1.Layer = "MapResourceManager1::MapResourceItem0::" + querylayer;
MapResourceManager mr = MapResourceManager1;
MapTips1.Features = null;
MapTips1.WhereClause = "2>1";
// MapTips1.Map = map.ClientID;
//刷新MapTips1
Map1.ZoomToFullExtent();
Map1.Refresh();
}
///
/// 寻找位置并且标注maptips
///
///
private void FindSpace(string Input)
{
int featurecount = 0;
//获取usa的MapFunctionality、Resource
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)Map1;
ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mf = (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality)map.GetFunctionality("MapResourceItem0");
ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gr = mf.Resource;
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qf;
string[] lids;
string[] lnames;
//创建QueryFunctionality
qf = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gr.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
//查询图层id、名称
qf.GetQueryableLayers(null, out lids, out lnames);
//获取maptips的MapFunctionality、Resource
ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mf_maptips = (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality)map.GetFunctionality("maptips");
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gr_matips = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)mf_maptips.Resource;
//创建FeatureGraphicsLayer
ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer gl_maptips = new ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer("maptips", ESRI.ArcGIS.ADF.Web.FeatureType.Point, new ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer(ESRI.ArcGIS.ADF.Web.FeatureType.Point, System.Drawing.Color.Red));
//给新建的FeatureGraphicsLayer添加字段
gl_maptips.Columns.Add("fid", typeof(Int32));
gl_maptips.Columns.Add("id", typeof(Int32));
gl_maptips.Columns.Add("name", typeof(string));
gr_matips.Graphics.Tables.Clear();
IMapFunctionality pMapfun;
DataTable dt4 = null;
ESRI.ArcGIS.ADF.Web.SpatialFilter sfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
//获取查询关键字
for (int i = 0; i < lids.Length; i++)
{
//设置过滤条件
sfilter.ReturnADFGeometries = true;
sfilter.MaxRecords = 100;
sfilter.Geometry = null;
sfilter.WhereClause = "NAME LIKE '" + Input + "%'";
//查询并且把结果放在dt4中
dt4 = qf.Query(null, lids[i], sfilter);
if (dt4 != null)
{
//累加查询到的结果数
featurecount += dt4.Rows.Count;
//对查询到结果进行遍历,更加不同的类型在FeatureGraphicsLayer中生成显示点
foreach (DataRow dr in dt4.Rows)
{
int objectid = Int32.Parse(dr["fid"].ToString());
int layerid = Int32.Parse(lids[i]);
pMapfun = mf;
if (pMapfun.Resource is ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
{
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal pLocal = pMapfun.Resource as ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal;
ESRI.ArcGIS.Carto.IMapServer pMapServer = (ESRI.ArcGIS.Carto.IMapServer)pLocal.MapServer;
//获取Objects
ESRI.ArcGIS.Carto.IMapServerObjects pMapServerObjects = pMapServer as ESRI.ArcGIS.Carto.IMapServerObjects;
//用Objects的方法获取FeatureLayer
ESRI.ArcGIS.Carto.IFeatureLayer pFLayer = pMapServerObjects.get_Layer(pMapServer.get_MapName(0), layerid) as ESRI.ArcGIS.Carto.IFeatureLayer;
ESRI.ArcGIS.Geodatabase.IFeatureClass pFClass = pFLayer.FeatureClass;
//根据objectid获取Feature
ESRI.ArcGIS.Geodatabase.IFeature pFeature = pFClass.GetFeature(objectid);
//获取Geometry
ESRI.ArcGIS.Geometry.IGeometry pGeometry = pFeature.Shape;
//查询结果为点的时候
if (pGeometry.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
{
//新建点并且添加到FeatureGraphicsLayer
IPoint ippoint = pGeometry as IPoint;
ESRI.ArcGIS.ADF.Web.Geometry.Point adfpt = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPoint(ippoint);
DataRow dtr = gl_maptips.Add(adfpt);
//添加属性值
try
{
dtr["id"] = objectid;
dtr["id"] = dr["id"];
dtr["name"] = dr["name"];
}
catch
{
dtr["fid"] = objectid;
dtr["id"] = 0;
dtr["name"] = dr["name"];
}
}
//查询结果为线的时候
if (pGeometry.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
{
IPolyline ippolyline = pGeometry as IPolyline;
ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)ippolyline;
ESRI.ArcGIS.ADF.Web.Geometry.Point[] new_adf_points = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPointCollection(com_pointcollection);
ESRI.ArcGIS.ADF.Web.Geometry.Point adfpt = new ESRI.ArcGIS.ADF.Web.Geometry.Point();
//获取线的中间一个点
adfpt = new_adf_points[new_adf_points.Length / 2];
DataRow dtr = gl_maptips.Add(adfpt);
try
{
dtr["fid"] = objectid;
dtr["id"] = dr["id"];
dtr["name"] = dr["name"];
}
catch
{
dtr["fid"] = objectid;
dtr["id"] = 0;
dtr["name"] = dr["name"];
}
}
//查询结果为面的时候
if (pGeometry.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
{
IPolygon ippolygon = pGeometry as IPolygon;
//面曲线的开始点
ESRI.ArcGIS.Geometry.IPoint ippoint = ippolygon.FromPoint;
ESRI.ArcGIS.ADF.Web.Geometry.Point adfpt = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPoint(ippoint);
DataRow dtr = gl_maptips.Add(adfpt);
try
{
dtr["fid"] = objectid;
dtr["id"] = dr["id"];
dtr["name"] = dr["NAME"];
}
catch
{
dtr["fid"] = objectid;
dtr["id"] = 0;
dtr["name"] = dr["NAME"];
}
}
}//end if
}//end foreach
}
if (featurecount >= 1) break;
}// end for
//把FeatureGraphicsLayer添加到maptips
gr_matips.Graphics.Tables.Add(gl_maptips);
if (featurecount > 0)
{
//设置地图视图范围
//ESRI.ArcGIS.ADF.Web.Geometry.Geometry geom;
//ESRI.ArcGIS.ADF.Web.Geometry.Envelope env = new ESRI.ArcGIS.ADF.Web.Geometry.Envelope(double.MaxValue, double.MaxValue, double.MinValue, double.MinValue);
//foreach (DataRow row in gl_maptips.Rows)
//{
// geom = gl_maptips.GeometryFromRow(row);
// env.Union(geom);
//}
//int percent = 20;
//double newwidth, newheight;
//newwidth = map.GetFullExtent().Width * (percent / 100);
//newheight = map.GetFullExtent().Height * (percent / 100);
//env.XMin -= newwidth;
//env.XMax += newwidth;
//env.YMin -= newheight;
//env.YMax += newheight;
Map1.Extent = Map1.GetFullExtent();// = (ESRI.ArcGIS.ADF.Web.Geometry.Envelope)env.Clone();//设置map显示区域
//设置MapTips1的属性
MapTips1.FeatureLimit = 20;
MapTips1.Layer = "MapResourceManager1::maptips::maptips";
MapResourceManager mr = MapResourceManager1;
MapTips1.HeaderFormatString = "
MapTips1.BodyFormatString = "";
MapTips1.Features = null;
MapTips1.WhereClause = "2>1";
// MapTips1.Map = map.ClientID;
//刷新MapTips1
//if (Map1.ImageBlendingMode == ImageBlendingMode.Browser)
//{
// Map1.RefreshResource("MapResourceItem0");
//}
//else
//{
Map1.Refresh();
//}
//m_ADFCallbackResultCollection.Add(MapTips1.CallbackResults[0]);
//m_ADFCallbackResultCollection.Add(Map1.CallbackResults[0]);
}
}
- ARCGIS经典代码
- 经典代码
- 代码经典
- ArcGis 读取Shape文件 代码
- 经典的网页代码
- 经典Robocode例子代码
- php 经典代码
- ASP经典代码例子
- 经典网页代码
- 网页经典代码,收藏!!!!!!!!!
- 网页经典代码
- 网页经典代码
- 网页经典代码
- 网页经典代码
- javascript 经典代码
- 经典的网页代码
- 网页经典代码
- 网页经典代码
- 第 1 章 UML初览
- padding and layout_margin
- 深入 GalCon:Python、游戏开发和人工智能
- 2.1 静态视图
- layout_gravity and gravity
- ARCGIS经典代码
- 分页控件存储过程
- zigbee在无线抄表(水表、电表、气表、热表)中应用
- #pragma pack(push,1) (pop)
- WINCE的批处理
- Silverlight 3 DataGrid 一
- Flex(AS 3.0)实现快捷键功能--监听键盘事件
- Spring+log4j
- 集成spring security3.0权限控制