连接SDE是正常,但地图上就是不显示那图层?
是9.3版的
//License
IAoInitialize pAoInit = new AoInitializeClass();
pAoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);
//Workspace
IWorkspaceFactory pWorkspaceFactory;
pWorkspaceFactory = new SdeWorkspaceFactoryClass();
//PropertySet
IPropertySet pPropertySet;
pPropertySet = new PropertySetClass();
//pPropertySet.SetProperty("Service", "mapdataserver");
//设置数据库服务器名
pPropertySet.SetProperty("SERVER", "mapdataserver"); //\\sqlexpress
//设置SDE的端口,这是安装时指定的,默认安装时port:
pPropertySet.SetProperty("INSTANCE", "5151");
//SDE的用户名
pPropertySet.SetProperty("USER", "sa");
//密码
pPropertySet.SetProperty("PASSWORD", "123456");
//设置数据库的名字 sde_sz1 szSDE
pPropertySet.SetProperty("DATABASE", "GZmap");
//SDE的版本,在这为默认版本
pPropertySet.SetProperty("VERSION", "dbo.DEFAULT");
//IFeatureWorkspace对象
IFeatureWorkspace pSdeWorkspace;
IFeatureDataset pFeatureDataset;
IFeatureClass pFeatureClass;
//图层
ESRI.ArcGIS.Carto.IFeatureLayer layer;
//连接
pSdeWorkspace = (IFeatureWorkspace)pWorkspaceFactory.Open(pPropertySet, 0);
//取数据
//pFeatureDataset = pSdeWorkspace.OpenFeatureDataset("szmap.DBO.公司企业");
pFeatureClass = pSdeWorkspace.OpenFeatureClass("szmap.DBO.铁路"); //行政区域 铁路
//定义图层
layer = new FeatureLayerClass();
//设定layer的FeatureClass属性
layer.FeatureClass = pFeatureClass;
layer.Name = pFeatureClass.AliasName;
ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem t = new ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem();
t.Data = pFeatureClass;
//MapResourceManager1.ResourceItems.Clear();
int n = MapResourceManager1.ResourceItems.Count;
MapResourceManager1.ResourceItems.Insert(n, t);
MapResourceManager1.ResourceItems.Add(t);
MapResourceManager1.CreateResource(t);
Map1.InitializeFunctionalities();
if (Map1.ImageBlendingMode == ImageBlendingMode.WebTier)
{
Map1.Refresh();
}
else
{
Map1.RefreshResource("MapResourceManager1");
}
Response.Write(MapResourceManager1.ResourceItems.Count.ToString());
Map1.Refresh();
前台
<form id="form1" runat="server">
<div>
<esri:MapResourceManager ID="MapResourceManager1" runat="server">
</esri:MapResourceManager>
<esri:Map ID="Map1" runat="server" Height="200px" Width="300px"
MapResourceManager="MapResourceManager1" BorderStyle="Solid"
BorderColor="Green" PrimaryMapResource="MapResourceItem0"
ClientToolGraphicsWidth="10" BackColor="#CCFFFF">
</esri:Map>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
</form>
连接SDE是正常,但地图上就是不显示那图层?
[解决办法]
用arcmap或者arccatalog先看看是不是图层数据有问题
然后就是看看页面上的坐标范围,地图服务的图层可见范围设置等