iwannafly
路人甲
路人甲
  • 注册日期2005-12-03
  • 发帖数35
  • QQ
  • 铜币274枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1916回复:3

设置点图层符号

楼主#
更多 发布于:2006-09-05 11:39
<P>我是从serverstyle文件中读取符号并渲染图层</P>
<P>代码如下:<BR>   String markname;<BR>   ServerStyleGallery pStyleGlry=new ServerStyleGalleryClass ();<BR>   IEnumStyleGalleryItem pEnumStyle;<BR>   IStyleGalleryItem pStyleItem;<BR>   IStyleGalleryStorage pStylStor;<BR>   pStylStor=(IStyleGalleryStorage)pStyleGlry;<BR>   pStyleGlry.ImportStyle ("C:/Program Files/ArcGIS/Styles/Caves.ServerStyle");<BR>   pStyleGlry.LoadStyle ("C:/Program Files/ArcGIS/Styles/Caves.ServerStyle","Marker Symbols");</P>
<P>   pStylStor.TargetFile="C:/Program Files/ArcGIS/Styles/Caves.ServerStyle";<BR>   pStylStor.AddFile ("C:/Program Files/ArcGIS/Styles/Caves.ServerStyle");</P>
<P>   if(pStyleGlry==null)<BR>   {<BR>    MessageBox.Show ("i am sorry");<BR>   }<BR>   else<BR>   {<BR>    pEnumStyle=pStyleGlry.get_Items ("Marker Symbols",null,null);<BR>    pEnumStyle.Reset ();<BR>    pStyleItem=pEnumStyle.Next ();<BR>    ISymbol sym;<BR>    sym=(ISymbol)pStyleItem.Item ;;<BR>    IActiveView activeView =(IActiveView)axMapControl1.ActiveView .FocusMap ;//.Map ;//mxDoc.FocusMap as IActiveView;<BR>    IScreenDisplay screenDisplay = activeView.ScreenDisplay;<BR>    screenDisplay.SetSymbol (sym);<BR>    activeView.Refresh ();<BR>    ISimpleRenderer sr=new SimpleRendererClass ();</P>
<P>    sr.Symbol =sym;<BR>    IGeoFeatureLayer fl;<BR>    fl=(IGeoFeatureLayer)m_pCurrentLayer;<BR>    fl.Renderer =(IFeatureRenderer)sr;<BR>   IActiveView ppac1=(IActiveView)axMapControl1.Map;<BR>    ppac1.Refresh ();<BR>   }</P>
<P>但是总是在pEnumStyle=pStyleGlry.get_Items ("Marker Symbols",null,null);<BR>处报错,不知为何,请各位老大指教!!</P>
<P><BR> </P>
喜欢0 评分0
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-09-05 14:33
<TABLE cellSpacing=4 cols=2 cellPadding=4><TR vAlign=top><TD class=t width="15%"><I>object</I></TD><TD class=t width="85%">An <a>object expression</A> that evaluates to an object in the Applies To list.</TD></TR><TR vAlign=top><TD class=t width="15%"><I>variable</I></TD><TD class=t width="85%">A reference to an object that implements <B><a href="mk:@MSITStore:C:\Program%20Files\ArcGIS\DeveloperKit\Help\COM\VB\esriDisplay.chm::/IEnumStyleGalleryItem.htm" target="_blank" >IEnumStyleGalleryItem</A></B>.</TD></TR><TR vAlign=top><TD class=t width="15%"><I>className</I></TD><TD class=t width="85%">Required. A <a>string expression</A> that represents the className.</TD></TR><TR vAlign=top><TD class=t width="15%"><I>styleSet</I></TD><TD class=t width="85%">Required. A <a>string expression</A> that represents the styleSet.</TD></TR><TR vAlign=top><TD class=t width="15%"><I>Category</I></TD><TD class=t width="85%"><P>Required. A <a>string expression</A> that represents the Category.</P><P>你没把错误信息贴出来!我估计是第二和第三个参数为必须字段!而你全是null!所以才运行不了</P></TD></TR></TD></TR></TABLE>
[此贴子已经被作者于2006-9-6 12:32:01编辑过]
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
iwannafly
路人甲
路人甲
  • 注册日期2005-12-03
  • 发帖数35
  • QQ
  • 铜币274枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-09-05 15:32
<P>错误提示如下:</P>
<P>未处理的“System.Runtime.InteropServices.COMException”类型的异常出现在 ToolbarMenu.exe 中。</P>
<P>其他信息: 未指定的错误</P>
<P>pEnumStyle=pStyleGlry.get_Items ("Marker Symbols","","");<BR>这一句原来这样是可以执行的,但是当时是在安装了arcinfo(arcmap)的情况下.</P>
<P><BR> </P>
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-09-06 12:37
既然以前在装了arcinfo的情况下能跑,而现在不能跑,那说明了程序代码是没问题的!唯一的原因就是你的环境问题等等,或者你的目录C:/Program Files/ArcGIS/Styles/Caves.ServerStyle不存在,你只能自己检查了
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
游客

返回顶部