dengkz
路人甲
路人甲
  • 注册日期2009-01-04
  • 发帖数2
  • QQ
  • 铜币108枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1537回复:1

连接SDE是正常,但地图上就是不显示那图层?

楼主#
更多 发布于:2010-01-06 13:35
<P>//License<BR>        IAoInitialize pAoInit = new AoInitializeClass();<BR>        pAoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);</P>

<P><BR>        //Workspace<BR>        IWorkspaceFactory pWorkspaceFactory;<BR>        pWorkspaceFactory = new SdeWorkspaceFactoryClass();</P>

<P>        //PropertySet<BR>        IPropertySet pPropertySet;<BR>        pPropertySet = new PropertySetClass();</P>
<P><BR>        //pPropertySet.SetProperty("Service", "mapdataserver");</P>
<P><BR>        //设置数据库服务器名 <BR>        pPropertySet.SetProperty("SERVER", "mapdataserver");  //\\sqlexpress</P>
<P><BR>        //设置SDE的端口,这是安装时指定的,默认安装时port:<BR>        pPropertySet.SetProperty("INSTANCE", "5151");</P>
<P><BR>        //SDE的用户名 <BR>        pPropertySet.SetProperty("USER", "sa");</P>
<P><BR>        //密码<BR>        pPropertySet.SetProperty("PASSWORD", "123456");</P>
<P><BR>        //设置数据库的名字  sde_sz1 szSDE <BR>        pPropertySet.SetProperty("DATABASE", "GZmap");</P>
<P><BR>        //SDE的版本,在这为默认版本<BR>        pPropertySet.SetProperty("VERSION", "dbo.DEFAULT");</P>

<P>        //IFeatureWorkspace对象<BR>        IFeatureWorkspace pSdeWorkspace;<BR>        IFeatureDataset pFeatureDataset;<BR>        IFeatureClass pFeatureClass;</P>

<P>        //图层<BR>        ESRI.ArcGIS.Carto.IFeatureLayer layer;</P>

<P>        //连接<BR>        pSdeWorkspace = (IFeatureWorkspace)pWorkspaceFactory.Open(pPropertySet, 0);</P>
<P><BR>        //取数据<BR>        //pFeatureDataset = pSdeWorkspace.OpenFeatureDataset("szmap.DBO.公司企业");<BR>        pFeatureClass = pSdeWorkspace.OpenFeatureClass("szmap.DBO.铁路");   //行政区域 铁路</P>
<P><BR>        //定义图层<BR>        layer = new FeatureLayerClass();</P>
<P>        //设定layer的FeatureClass属性<BR>        layer.FeatureClass = pFeatureClass;<BR>        layer.Name = pFeatureClass.AliasName;</P>

<P>        ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem t = new ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem();<BR>        t.Data = pFeatureClass;</P>
<P>        //MapResourceManager1.ResourceItems.Clear();</P>
<P>        int n = MapResourceManager1.ResourceItems.Count;<BR>        MapResourceManager1.ResourceItems.Insert(n, t);</P>
<P>        MapResourceManager1.ResourceItems.Add(t);<BR>        MapResourceManager1.CreateResource(t);<BR>        <BR>        </P>
<P>        Map1.InitializeFunctionalities();</P>
<P>        if (Map1.ImageBlendingMode == ImageBlendingMode.WebTier)<BR>        {<BR>            Map1.Refresh();<BR>        }<BR>        else<BR>        {<BR>            Map1.RefreshResource("MapResourceManager1");<BR>        }</P>
<P>        Response.Write(MapResourceManager1.ResourceItems.Count.ToString());<BR>        Map1.Refresh();</P>


<P>前台</P>
<P>    <form id="form1" runat="server"><BR>    <div><BR>    </P>
<P>        <esri:MapResourceManager ID="MapResourceManager1" runat="server"><BR>        </esri:MapResourceManager><BR>        <BR>        <esri:Map ID="Map1" runat="server" Height="200px" Width="300px"<BR>             MapResourceManager="MapResourceManager1" BorderStyle="Solid" <BR>            BorderColor="Green" PrimaryMapResource="MapResourceItem0" <BR>            ClientToolGraphicsWidth="10" BackColor="#CCFFFF"><BR>        </esri:Map><BR>    <BR>        <BR>        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /><BR>    <BR>    </div><BR>    </form></P>


<P>连接SDE是正常,但地图上就是不显示那图层?<BR></P>
喜欢0 评分0
dengkz
路人甲
路人甲
  • 注册日期2009-01-04
  • 发帖数2
  • QQ
  • 铜币108枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2010-01-06 13:42
是9.3版的
举报 回复(0) 喜欢(0)     评分
游客

返回顶部