Select to view content in your preferred language

Centering a Graphic on a GPS coordinate

676
3
10-11-2010 10:00 AM
AlexAgranov
Emerging Contributor
I figured out that I need to set the OffsetX/OffsetY properties. Hardcoding the values managed to center it, but I'd much prefer to calculate the values based on the total size of the ControlTemplate I'm using. Unfortunately I can't seem to find a way to get the size of that at run time.
0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor
If you use a custom symbol template, try and place your element so it's centered at 0,0 in it's local coordinate system regardless of size, and you won't have to muck around with offsets.
0 Kudos
AlexAgranov
Emerging Contributor
If you use a custom symbol template, try and place your element so it's centered at 0,0 in it's local coordinate system regardless of size, and you won't have to muck around with offsets.


More specifically what's happening is template's left top corner is placed on the GPS coordinate. I'm not sure what you mean by local coordinate system for the template relative to the map?
0 Kudos
dotMorten_esri
Esri Notable Contributor
I mean relative to the symbol element.
Ie. centering rectangle on the parent grid's 0,0 using negative margin (If root is a Canvas, use Canvas.Left/Top):
<ControlTemplate>
  <Grid>
    <Rectangle Margin="-10,-10,0,0" Width="20" Height="20" Fill="Green" />
  </Grid>
</ControlTemplate>
0 Kudos