Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

VB.Net - ArcGIS 10: ISimpleMarkerSymbol and IStyleGalleryItem

$
0
0
Dear all:

I would like to asign different marker symbols to an unique value renderer. But at the line "pMarkerSymbol1 = pStyleGalleryItem.Item" in the Do while ... Loop it gives me an error.

I have to use the ISimpleMarkerSymbol because I have to change the Outline.

Thanks for your help.
Anika

Sub prueba()

Dim pBlack As IColor
pBlack = New RgbColor
pBlack.RGB = RGB(0, 0, 0)

Dim pMarkerSymbol1 As ISimpleMarkerSymbol = New SimpleMarkerSymbol
Dim pMarkerSymbol2 As ISimpleMarkerSymbol = New SimpleMarkerSymbol
Dim pMarkerSymbol3 As ISimpleMarkerSymbol = New SimpleMarkerSymbol
Dim pMarkerSymbol4 As ISimpleMarkerSymbol = New SimpleMarkerSymbol

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFLayer As IFeatureLayer

pMxDoc = My.ArcMap.Document
pMap = pMxDoc.FocusMap
pFLayer = pMap.Layer(0)

Dim pMxApp As IMxApplication
Dim pGeoFLayer As IGeoFeatureLayer
Dim pSDisplay As IScreenDisplay

pMxApp = My.ThisApplication
pGeoFLayer = pFLayer
pSDisplay = pMxApp.Display
Dim pSRenderer As ISimpleRenderer

pSRenderer = New SimpleRenderer
Dim pStyleGallery As IStyleGallery
pStyleGallery = pMxDoc.StyleGallery
'Dim pStyleGalleryClass As IStyleGalleryClass
Dim pEnumStyGall As IEnumStyleGalleryItem

Dim pStyleGalleryItem As IStyleGalleryItem
pEnumStyGall = pStyleGallery.Items("marker symbols", "ESRI.Style", "")
pEnumStyGall.Reset()
pStyleGalleryItem = pEnumStyGall.Next



Do While Not pStyleGalleryItem Is Nothing
If pStyleGalleryItem.Name = "Simple Circle 1" Then
pMarkerSymbol1 = pStyleGalleryItem.Item
Debug.Print(pStyleGalleryItem.Name)
Exit Do
End If
pStyleGalleryItem = pEnumStyGall.Next
Loop


Do While Not pStyleGalleryItem Is Nothing
If pStyleGalleryItem.Name = "Circle 4" Then
pMarkerSymbol2 = pStyleGalleryItem.Item
Debug.Print(pStyleGalleryItem.Name)
Exit Do
End If
pStyleGalleryItem = pEnumStyGall.Next
Loop


Do While Not pStyleGalleryItem Is Nothing
If pStyleGalleryItem.Name = "Square 6" Then
pMarkerSymbol3 = pStyleGalleryItem.Item
Debug.Print(pStyleGalleryItem.Name)
Exit Do
End If
pStyleGalleryItem = pEnumStyGall.Next
Loop


Do While Not pStyleGalleryItem Is Nothing
If pStyleGalleryItem.Name = "Triangle 4" Then
pMarkerSymbol4 = pStyleGalleryItem.Item
Debug.Print(pStyleGalleryItem.Name)
Exit Do
End If
pStyleGalleryItem = pEnumStyGall.Next
Loop


pMarkerSymbol1.Color = pBlack
pMarkerSymbol2.Color = pBlack
pMarkerSymbol3.Color = pBlack
pMarkerSymbol4.Color = pBlack

pMarkerSymbol1.Size = 6
pMarkerSymbol2.Size = 6
pMarkerSymbol3.Size = 6
pMarkerSymbol4.Size = 6

pMarkerSymbol1.Outline = 2
pMarkerSymbol2.Outline = 2
pMarkerSymbol3.Outline = 2
pMarkerSymbol4.Outline = 2

Dim pUniqueValueRenderer As IUniqueValueRenderer
pUniqueValueRenderer = New UniqueValueRenderer

Dim pTable As ITable
Dim pDisplayTable As IDisplayTable
pDisplayTable = pGeoFLayer
pTable = pDisplayTable.DisplayTable

With pUniqueValueRenderer
.FieldCount = 1
.Field(0) = pTable.Fields.Field(pTable.FindField("CodCita")).Name()
.UseDefaultSymbol = False
.AddValue(1, "Propia", pMarkerSymbol1)
.AddValue(2, "OtroAutor", pMarkerSymbol2)
.AddValue(3, "SinConfirmar", pMarkerSymbol3)
.AddValue(4, "Cultivado", pMarkerSymbol4)
End With

pGeoFLayer.Renderer = pUniqueValueRenderer
pMxDoc.UpdateContents()
pMxDoc.ActiveView.Refresh()

End Sub

Viewing all articles
Browse latest Browse all 1374

Trending Articles