Select to view content in your preferred language

add a line with arrow on graphiclayer

872
6
Jump to solution
06-06-2012 02:27 PM
JulieBiju
Occasional Contributor
How can i add a line with arrow in graphiclayer instead of DefaultLineSymbol.See the code below.

I saw the thread  http://forums.arcgis.com/threads/47767-Drawing-a-line-with-arrow-in-web-application-with-C-and-silve...
But how can i add ExtendedSymbols??? project in my webapplication(VB).Can anybdy help me in a detailed way????where i need to add this <extendedSymbols:ExtendedLineSymbol .....

Please help me

Draw line
  If recordcount > 1 Then                     Dim startPoint As New MapPoint(Startlong, Startlat)                     Dim endPoint As New MapPoint(Endlong, Endlat)                     Dim pointCollection As New ESRI.ArcGIS.Client.Geometry.PointCollection()                     pointCollection.Add(startPoint)                     pointCollection.Add(endPoint)                     Dim polyline As New ESRI.ArcGIS.Client.Geometry.Polyline()                     polyline.Paths.Add(pointCollection)                     Dim graphicLine As New Graphic() With                 {                     .Symbol = TryCast(LayoutRoot.Resources("DefaultLineSymbol"), Symbol),                     .Geometry = mercator.FromGeographic(polyline)                 }                     If (EventId1 = 12 And EventId2 = 14) Then ''excluding vehicle idle after journey end                     Else                         graphicsLayer.Graphics.Add(graphicLine)                     End If                 End If
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
1)
I am getting error "The type 'ArrowPatternTransformer' does not support direct content"

Sorry I forgot the CompositeTranform declaration.
This should be OK:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >   <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>     <extendedSymbols:ArrowPatternTransformer AtEnd="True" >       <extendedSymbols:ArrowPatternTransformer.CompositeTransform>         <CompositeTransform ScaleX="5" ScaleY="3" />       </extendedSymbols:ArrowPatternTransformer.CompositeTransform>     </extendedSymbols:ArrowPatternTransformer>   </extendedSymbols:ExtendedLineSymbol.GeometryTransformer> </extendedSymbols:ExtendedLineSymbol>


2) Not sure what you need exactly but you might not create the line graphic when Startlon==Endlong AND Startlat == Endlat
or use a thredshold based on the length

View solution in original post

0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
You need to get the sources and compile the 'ExtendedSymbols' project either in your solution or in another solution.

Then, in your VB project, you need to reference the ExtendedSymbols dll.

Then define your lineSymbol in the ressources of your main page:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >
  <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
    <extendedSymbols:ArrowPatternTransformer AtEnd="True" />
  </extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
</extendedSymbols:ExtendedLineSymbol>


and finally use that line symbol as any other symbol (either to set the symbol of a graphic or to initialize a renderer...)
0 Kudos
JulieBiju
Occasional Contributor
Wowww...Working perfect ...Thank u so much...

1.How can i reduce the redcolour arrow size?

2.Sometimes 2 graphics will add on the same location with different attribute.This time only i can see the arrow without line.How can i avoid this case?


With Lottssssss Thankssssss
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Wowww...Working perfect ...Thank u so much...

1.How can i reduce the redcolour arrow size?

2.Sometimes 2 graphics will add on the same location with different attribute.This time only i can see the arrow without line.How can i avoid this case?


With Lottssssss Thankssssss


1. You have to set a CompositeTransform that can scale, skew, rotate or translate any existing pattern.

Example:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >
  <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
    <extendedSymbols:ArrowPatternTransformer AtEnd="True" >
      <CompositeTransform ScaleX="5" ScaleY="3" />
    </extendedSymbols:ArrowPatternTransformer>
  </extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
</extendedSymbols:ExtendedLineSymbol>


2. Not done in the sample but you might do it by tweaking the AddPatterns code for adding the pattern only if the geometry path has a length greater than a tolerance threshold
0 Kudos
JulieBiju
Occasional Contributor
<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >
  <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
    <extendedSymbols:ArrowPatternTransformer AtEnd="True" >
      <CompositeTransform ScaleX="5" ScaleY="3" />
    </extendedSymbols:ArrowPatternTransformer>
  </extendedSymbols:ExtendedLineSymbol.GeometryTransformer>
</extendedSymbols:ExtendedLineSymbol>


I am getting error "The type 'ArrowPatternTransformer' does not support direct content"

2:
Not done in the sample but you might do it by tweaking the AddPatterns code for adding the pattern only if the geometry path has a length greater than a tolerance threshold

Can u help me with the folowing code ?
How can i check this??


         Dim gpsNMEASentences As String = "$GPGGA, 92204.9, " & e.Result(Loopcnt).ETLat & ", N," & e.Result(Loopcnt).ETLon & ", W, 1, 04, 2.4, 25.7, M,,,,*75"
            Dim gpsNMEASentenceArray() As String = gpsNMEASentences.Split(ControlChars.Lf)
            Dim gpsNMEASentence() As String = gpsNMEASentenceArray(0).Split(","c)
            ''.Geometry = mercator.FromGeographic(New MapPoint(Convert.ToDouble(gpsNMEASentence(4)), Convert.ToDouble(gpsNMEASentence(2)))),
            Dim graphic As New Graphic() With
                {
                    .Geometry = New MapPoint(Convert.ToDouble(gpsNMEASentence(4)), Convert.ToDouble(gpsNMEASentence(2))),
                    .Symbol = TryCast(LayoutRoot.Resources(colourstyle), Symbol)
                }
            Dim strhotspot As String = ""
            strhotspot = "VEHICLE: " & Trim(TryCast(CmbFahrname.SelectedItem, comboloadclass).ename.ToString()) & ", DATETIME: " & e.Result(Loopcnt).ETdatedisplay & ", LOCATION: " & e.Result(Loopcnt).ETLocationName & ", SPEED: " & e.Result(Loopcnt).ETspeed & ", STATUS: " & Status
            graphic.Attributes.Add("STRHOTSPOT", strhotspot)
            AddHandler graphic.MouseLeave, AddressOf Graphic_MouseLeave
            AddHandler graphic.MouseEnter, AddressOf Graphic_MouseEnter

            'Delete the existing find object and add the new one
            If (Not MyMap Is Nothing) Then
                If recordcount = 1 Then
                    If (EventId1 = 12 And EventId2 = 14) Then ''excluding vehicle idle after journey end
                    Else
                        graphicsLayer.Graphics.Add(graphic)
                    End If
                Else
                    If (EventId1 = 12 And EventId2 = 14) Then ''excluding vehicle idle after journey end
                    Else
                        graphicsLayer.Graphics.Add(graphic)
                    End If
                End If
                ''adding lines''''''''''''''''''
                If recordcount > 1 Then
                    Dim startPoint As New MapPoint(Startlong, Startlat)
                    Dim endPoint As New MapPoint(Endlong, Endlat)
                    Dim pointCollection As New ESRI.ArcGIS.Client.Geometry.PointCollection()
                    pointCollection.Add(startPoint)
                    pointCollection.Add(endPoint)
                    Dim polyline As New ESRI.ArcGIS.Client.Geometry.Polyline()
                    polyline.Paths.Add(pointCollection)
                    Dim graphicLine As New Graphic() With
                {
                    .Symbol = TryCast(LayoutRoot.Resources("arrowLineSymbol"), Symbol),
                    .Geometry = polyline
                }
                    '.Geometry = mercator.FromGeographic(polyline)
                    If (EventId1 = 12 And EventId2 = 14) Then ''excluding vehicle idle after journey end
                    Else
                        graphicsLayer.Graphics.Add(graphicLine)
                    End If
                End If
0 Kudos
DominiqueBroux
Esri Frequent Contributor
1)
I am getting error "The type 'ArrowPatternTransformer' does not support direct content"

Sorry I forgot the CompositeTranform declaration.
This should be OK:

<extendedSymbols:ExtendedLineSymbol x:Key="arrowLineSymbol" Fill="Red" >   <extendedSymbols:ExtendedLineSymbol.GeometryTransformer>     <extendedSymbols:ArrowPatternTransformer AtEnd="True" >       <extendedSymbols:ArrowPatternTransformer.CompositeTransform>         <CompositeTransform ScaleX="5" ScaleY="3" />       </extendedSymbols:ArrowPatternTransformer.CompositeTransform>     </extendedSymbols:ArrowPatternTransformer>   </extendedSymbols:ExtendedLineSymbol.GeometryTransformer> </extendedSymbols:ExtendedLineSymbol>


2) Not sure what you need exactly but you might not create the line graphic when Startlon==Endlong AND Startlat == Endlat
or use a thredshold based on the length
0 Kudos
MaximPetroshenko
New Contributor
Sorry, I did not find where I can download this library... could you give me a link?
0 Kudos