阅读:1916回复:3
设置点图层符号
<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> |
|
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编辑过]
|
|
|
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> |
|
3楼#
发布于:2006-09-06 12:37
既然以前在装了arcinfo的情况下能跑,而现在不能跑,那说明了程序代码是没问题的!唯一的原因就是你的环境问题等等,或者你的目录C:/Program Files/ArcGIS/Styles/Caves.ServerStyle不存在,你只能自己检查了
|
|
|