Solved! Go to Solution.
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
Do you know of a way to translate pixels to esri coords without access to the Maps MapToScreen function?