Select to view content in your preferred language

Location of PictureMarkerSymbol vs MarkerSymbol

4103
15
11-02-2010 09:38 AM
KeithNightlinger
Emerging Contributor
As I zoom in and out of my application the PictureMarkerSymbol and the MarkerSymbol with the Image brush don't appear in its true location and as a user zooms out it gets farther and farther away. 

I have set the offsetX and offsetY and when zoomed all the way in it shows where it is supposed to, but when zoomed out it moves it away. 

In contrast the strobe marker symbol (from samples) shows exactly where it is supposed to, no matter the scale.

I have tried setting the ScaleTransform, but that wasn't it.

What am I missing?  The issue is I have emergency vehicles appearing as though they are in completely different city and my users need to have an broad view of where all the vehicles are at.

Thanks in advance,

Keith
0 Kudos
15 Replies
João_VictorCoelho
Emerging Contributor
Can you just post your code?
0 Kudos
KeithNightlinger
Emerging Contributor
PictureMarker Symbol snippet

<esriSymbols:PictureMarkerSymbol x:Name="PoliceLeftPnt" Source="/Images/vehicles/policecarL.png" Width="40" Height="40" OffsetX="20" OffsetY="20"/>

Image Brush snippet
<ImageBrush ImageSource="/Images/vehicles/policecarL.png" x:Name="PoliceLeftImageBrush" />
            <esriSymbols:MarkerSymbol x:Name="PoliceLeft"  OffsetX="20" OffsetY="20">
                <esriSymbols:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid RenderTransformOrigin="0.5,0.5" Width="80" Height="80" >
                            <!--<Grid.RenderTransform>
                                <RotateTransform Angle ="{Binding Attributes[Heading]}" />
                            </Grid.RenderTransform>-->
                        <Ellipse x:Name="Element" Fill="{StaticResource PoliceLeftImageBrush}" Opacity="1" Width="40" Height="40">
                            <Ellipse.Stroke>
                                <SolidColorBrush />
                            </Ellipse.Stroke>
                                <Ellipse.RenderTransform>
                                    <ScaleTransform />
                                </Ellipse.RenderTransform>
                            </Ellipse>
                         </Grid>
                    </ControlTemplate>
                </esriSymbols:MarkerSymbol.ControlTemplate>
            </esriSymbols:MarkerSymbol>
0 Kudos
JenniferNery
Esri Regular Contributor
I tried both of your symbols and they look fine to me when I zoom in and out of the map, they are still located at the point where I placed them.

The only change I would add is in your PoliceLeft MarkerSymbol, the offsets need to be 40, to account for the Grid that contains the ImageBrush.

Below are two graphics located in Redlands and Moreno Valley. I used this as my street map: http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer
<esri:Graphic Symbol="{StaticResource PoliceLeftPnt}">
 <esri:MapPoint X="-117.171952484027" Y="34.050984501128"/>
</esri:Graphic>
<esri:Graphic Symbol="{StaticResource PoliceLeft}">
 <esri:MapPoint X="-117.22672317423" Y="33.9176215942354"/>
</esri:Graphic>
0 Kudos
KeithNightlinger
Emerging Contributor
Thanks Jennifer, I made the offset change and restarted Visual Studio and the markers are appearing where they should.  Not sure what happened there, but its working.

Keith
0 Kudos
BjørnarSundsbø
Deactivated User
Hi

I have pretty much the same problem, however, as I include a label (textblock) to the element, I can't set the offset to a fixed number of pixels. This is because the height and with of the label is dynamic. How can I do this in a dynamic way? I've tried RenderTransformOrigin and TranslateTransform with no apparent luck.
0 Kudos
JenniferNery
Esri Regular Contributor
Have you tried using TextSymbol instead?
0 Kudos
BjørnarSundsbø
Deactivated User
I can't use TextSymbol as I need to display an arrow pointing the direction a vehicle is driving, in addition to the text label.
0 Kudos
JenniferNery
Esri Regular Contributor
You can update the Offsets in code-behind:
 MarkerSymbol ms = this.LayoutRoot.Resources["MarkerSymbol"] as MarkerSymbol;
 ms.OffsetX = label.Length/2;
 ms.OffsetY = label.Length/2;


You can set them in relation to the label's length. Maybe do this on Graphic's AttributeValueChanged event?

or maybe use {Binding Attributes[label]} with a Converter that will calculate offset based on this value.
0 Kudos
BjørnarSundsbø
Deactivated User
The trouble with both those approaches is that I don't know the length (or tedious to calculate) of the label as it is a TextBlock, and can have any font size defined by the user. So the calculating the pixel width of characters to find out the width of the markerSymbol is quite complex. I then also have to include the width and height of the symbol (arrow) with margins etc, and add that to the logic of the converter, or whichever approach I use.
0 Kudos