Select to view content in your preferred language

Rotate arrow symbol based on the direction of GPS point

1240
6
Jump to solution
08-19-2013 06:22 PM
JulieBiju
Deactivated User
Thank u all...

How can I rotate an arrow symbol based on the direction of my GPS point?

The  direction of point is  in degrees. And this value is between 0 and 359 degree. (no decimal) .For example, 311 means 311 degree to the north. 0 means 0 degree to the north.


I tried the way mentioned below...Not success..please help needed...
If direction  = 253 Then                 colourstyle = "MyRotatingSymbolRenderer" end if               Dim graphic As New Graphic() With                 {                     .Geometry = New MapPoint(Convert.ToDouble(gpsNMEASentence(4)), Convert.ToDouble(gpsNMEASentence(2))),                     .Symbol = TryCast(LayoutRoot.Resources(colourstyle), Symbol)                 }



[HTML]

<esri:MarkerSymbol x:Name="MyRotatingMarkerSymbol" OffsetX="6" OffsetY="3">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid x:Name="ArrowGrid" RenderTransformOrigin="0.5,0.5" Background="Transparent" Width="6" Height="12">
                            <Path Data="M2.625,11.5 L0.5,9.375 L1.88125,9.375 L1.88125,0.5 L3.3687501,0.5 L3.3687501,9.375 L4.75,9.375 z"
                                  Fill="#FFF4F4F5" Margin="0.625,0.25,0.625,0.625" Stretch="Fill" Stroke="Black" UseLayoutRounding="False"/>
                            <Grid.RenderTransform>
                                <CompositeTransform Rotation="{Binding Attributes[WIND_DIRECT]}" ScaleX="2" ScaleY="2" />
                            </Grid.RenderTransform>
                        </Grid>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>
            <esri:SimpleRenderer x:Key="MyRotatingSymbolRenderer" Symbol="{StaticResource MyRotatingMarkerSymbol}" />[/HTML]
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
But how can I pass that from code behind????

Something like graphic.Attributes["WIND_DIRECT"] = direction;

View solution in original post

0 Kudos
6 Replies
JulieBiju
Deactivated User
any help pls
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I don't see in your code where you initialize the attribute 'WIND_DIRECT'.
At first glance, if this attribute was initialized, it should work.
0 Kudos
JulieBiju
Deactivated User
I don't see in your code where you initialize the attribute 'WIND_DIRECT'.
At first glance, if this attribute was initialized, it should work.


But how can I pass that from code behind????
0 Kudos
DominiqueBroux
Esri Frequent Contributor
But how can I pass that from code behind????

Something like graphic.Attributes["WIND_DIRECT"] = direction;
0 Kudos
JulieBiju
Deactivated User
Working fine...Thank u so much:)

  colourstyle = "MyRotatingMarkerSymbol"
            Dim graphic As New Graphic() With
                {
                    .Geometry = New MapPoint(Convert.ToDouble(gpsNMEASentence(4)), Convert.ToDouble(gpsNMEASentence(2))),
                    .Symbol = TryCast(LayoutRoot.Resources(colourstyle), Symbol)
                }

            graphic.Attributes("WIND_DIRECT") =val2.value
0 Kudos
JulieBiju
Deactivated User

I can Rotated an arrow with the code I mentioned above.

Is it possible to rotate a car icon with the same code?

I need to rotate the DefaultCArSymbol based on direction  instead of MyRotatingMarkerSymbol. For that How can I write the code?Pls HELP ME

<!--'realtime code added-->

            <esri:PictureMarkerSymbol x:Key="DefaultCArSymbol" OffsetX="8" OffsetY="8" Source="/ESRI-V-10-SIL4;component/Images/car-red-16x16.png" />

            <esri:MarkerSymbol x:Name="MyRotatingMarkerSymbol" OffsetX="6" OffsetY="3">

                <esri:MarkerSymbol.ControlTemplate>

                    <ControlTemplate>

                        <Grid x:Name="ArrowGrid" RenderTransformOrigin="0.5,0.5" Background="Transparent" Width="6" Height="12">

                            <Path Data="M2.625,11.5 L0.5,9.375 L1.88125,9.375 L1.88125,0.5 L3.3687501,0.5 L3.3687501,9.375 L4.75,9.375 z"

                                  Fill="#FFF4F4F5" Margin="0.625,0.25,0.625,0.625" Stretch="Fill" Stroke="Black" UseLayoutRounding="False"/>

                            <Grid.RenderTransform>

                                <CompositeTransform Rotation="{Binding Attributes[WIND_DIRECT]}" ScaleX="2" ScaleY="2" />

                            </Grid.RenderTransform>

                        </Grid>

                    </ControlTemplate>

                </esri:MarkerSymbol.ControlTemplate>

            </esri:MarkerSymbol>

0 Kudos