在引用中添加 Vishcious.ArcGIS.SLContrib.dll,该dll可以google搜索.
-
using System.Windows;
-
using Vishcious.ArcGIS.SLContrib;
-
-
private void InitShpFile()
-
{
-
StreamResourceInfo shpRes = Application.GetResourceStream(new Uri("shpres/县界.shp", UriKind.Relative));
-
StreamResourceInfo attrRes = Application.GetResourceStream(new Uri("shpres/县界.dbf", UriKind.Relative));
-
-
ShapeFile shapeFileReader = new ShapeFile();
-
-
shapeFileReader.ReadShapes(shpRes.Stream);
-
shapeFileReader.ReadAttributes(attrRes.Stream);
-
-
Graphic graphic = null;
-
for (int index = 0; index < shapeFileReader.Records.Count; index++)
-
{
-
ShapeFileRecord shpRecord = shapeFileReader.Records[index];
-
graphic = shpRecord.ToGraphic();
-
-
graphic.MouseLeftButtonDown += new MouseButtonEventHandler(GraphicsLayer_MouseLeftButtonDown);
-
graphic.MouseEnter += new MouseEventHandler(GraphicsLayer_MouseEnterEvent);
-
graphic.MouseLeave += new MouseEventHandler(GraphicsLayer_MouseLeaveEvent);
-
//采用地图中定义的样式
-
graphic.Symbol = HighlightFillSymbolName;
-
}
-
-
if (graphic != null)
-
{
-
//把图层添加到地图上
-
graphicsLayer.Graphics.Add(graphic);
-
}
-
}
阅读(6253) | 评论(0) | 转发(1) |