|
阅读:1899回复:4
[求助]IPolygon如何设置颜色?
<P>请问在同一shape文件中如何设置不同颜色的IPolygon?</P>
<P>急!</P> |
|
|
1楼#
发布于:2008-04-30 11:07
<P>是指专题图吗?用单一符号专题图示例:</P>
<P>//新建填充符合</P> <P>ISimpleFillSymbol pSimpleFillSyl=new SimpleFillSymbol();</P> <P>//设置填充符合的颜色样式等属性</P> <P>...</P> <P>//新建一个SimpleRenderer</P> <P><EM>I</EM>SimpleRenderer pSimpleRenderer=new SimpleRenderer();</P> <P>pSimpleRenderer.Symbol=pSimpleFillSyl;</P> <P>//获取图层</P> <P>IGeoFeatureLayer pGeoFeatureLayer=new GeoFeatureLayer();</P> <P>pGeoFeatureLayer=AxMapControl.Map.Layer(0);</P> <P>pGeoFeatureLayer.Render=pSimpleRenderer;</P> <P>//刷新</P> <P>AxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,Nothing,Nothing);</P> |
|
|
2楼#
发布于:2008-04-30 14:54
<P>谢谢,但是我想问的是:在一个shape文件中,不同的IPolygon设置不同的颜色?<BR> IPoint p = new PointClass();<BR> object Missing = Type.Missing;<BR> IPolygon polygon = new PolygonClass();<BR> //定义一个点的集合</P>
<P>/**/ IPointCollection ptCollect = polygon as IPointCollection;<BR> //定义一系列要添加到多边形上的点对象,并赋初始值<BR> p.PutCoords(473701, 3597969);<BR> ptCollect.AddPoint(p, ref Missing, ref Missing);<BR> p.PutCoords(473701, 3601969);<BR> ptCollect.AddPoint(p, ref Missing, ref Missing);<BR> p.PutCoords(474701, 3601969);<BR> ptCollect.AddPoint(p, ref Missing, ref Missing);<BR> p.PutCoords(474701, 3597969);<BR> ptCollect.AddPoint(p, ref Missing, ref Missing);</P> <P> feature.Shape = polygon;<BR> feature.Store();</P> <P>在这里polygon如何设置颜色?</P> |
|
|
3楼#
发布于:2008-05-13 21:57
2楼的办法会给整个层都变色,不能单独针对某个要素变色
|
|
|
4楼#
发布于:2008-05-26 20:15
<P>这段代码对面图层有效</P>
<P> MapMain.ActiveView.Get_FocusMap(pMap);</P> <P> //获取图层字段<BR> pMap.Get_Layer(6,Layer);<BR> FeatureLayer:=IFeatureLayer(layer);</P> <P> //显示选中点<BR> FeatureLayer.Search(nil,false,featureCursor);<BR> if featureCursor=nil then begin exit; end;</P> <P> pRender:=CoUniqueValueRenderer.Create as IUniqueValueRenderer;<BR> pRender.Set_FieldCount(1);</P> <P> featureCursor.NextFeature(feature);<BR> feature.Get_Fields(fields);<BR> fields.Get_Field(0,field);<BR> field.Get_Name(fname);</P> <P> pRender.Set_Field(0,fname);</P> <P> while feature<>nil do begin<BR> //根据不同的数据对要素显示不同的颜色;<BR> feature.Get_Value(0,value);<BR> if value>1 then begin<BR> pColor:=CoRgbColor.create as IColor;<BR> pColor.Set_RGB(RGB(255,0,0));<BR> end else begin<BR> pColor:=CoRgbColor.create as IColor;<BR> pColor.Set_RGB(RGB(255,255,0));<BR> end;</P> <P> FillSymbol:=CoSimpleFillSymbol.create as ISimpleFillSymbol;<BR> FillSymbol.Set_Color(pColor);<BR> pRender.AddValue(value,value,ISymbol(FillSymbol));<BR> featureCursor.NextFeature(feature);<BR> end;</P> <P> IGeoFeatureLayer(FeatureLayer)._Set_Renderer(pRender as IFeatureRenderer);<BR> MapMain.Update;<BR> MapMain.ActiveView.PartialRefresh(esriViewGeography,Layer,nil);</P> |
|