Select to view content in your preferred language

Offset for element Layer?

880
4
Jump to solution
07-16-2012 11:42 AM
JoshPorter
Occasional Contributor
Is there a way to set an offset for elements on an element layer like you can for graphics on a graphic layer?
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
There is nothing to do that out of the box.
But as the element position is drived by the attached property ElementLayer.Envelope, you could just apply the offset to this envelope.

View solution in original post

0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
There is nothing to do that out of the box.
But as the element position is drived by the attached property ElementLayer.Envelope, you could just apply the offset to this envelope.
0 Kudos
JoshPorter
Occasional Contributor
Do you know of a way to translate pixels to esri coords without access to the Maps MapToScreen function?
Right now i am having the element raise an event when it wants its position set and the element layer is executing the following function. This does work and satisfies my needs, but my curiosity is wondering if there is a way to do this from within the UIElement
 Private Sub ElementLocationSetRequestListener(pSender As MyUIElement)
        'WhereWeWantTheIcon is the geographical point at which we want the center of the icon. (expressed in latitude and longitude)
        Dim WhereWeWantTheIcon As ESRI.ArcGIS.Client.Geometry.MapPoint = mercator.FromGeographic(New ESRI.ArcGIS.Client.Geometry.MapPoint(pSender.Location.X, pSender.Location.Y))
        'ShiftedCenter will be the geographical poistion we tell the element it is at so it displays the asset icon at the right place on the map. This will be shifted down and to the right
        Dim ShiftedCenter As New ESRI.ArcGIS.Client.Geometry.MapPoint
        'screencords is our translator between pixels, lat/lon, and esri coords. We get the pixels from the upperleft corner of the actual point where we want the icon
        Dim screencoords As Point = Map.esriMap.MapToScreen(WhereWeWantTheIcon)
        'then we translate the icon using the elements actual width and height, as well as the icons distance from the top left in the MyUIElement object itself. It is a 24px square icon with a 20px distance from top and left, so 20+24/2=32
        ShiftedCenter = Map.esriMap.ScreenToMap(New Point(screencoords.X + pSender.ActualWidth / 2 - 32, screencoords.Y + pSender.ActualHeight / 2 - 32))
        ESRI.ArcGIS.Client.ElementLayer.SetEnvelope(pSender, New ESRI.ArcGIS.Client.Geometry.Envelope(ShiftedCenter, ShiftedCenter))
    End Sub
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Do you know of a way to translate pixels to esri coords without access to the Maps MapToScreen function?


Map resolution gives the size of one pixel in geographical coordinates.

So to translate pixels to map coordinates you can do  :  map.Resolution * pixels;
0 Kudos
JoshPorter
Occasional Contributor
Thank you!!!!
0 Kudos