calculating the envelope on a LineGeometry

11-30-2010 05:59 AM
New Contributor
I have a WPF pathGeometry part of a Canvas & I add the Canvas as a UIElement to the map ElementLayer - how do I calculate the envelope for the ElementLayer to properly display the PathGeometry?
0 Kudos
1 Reply
New Contributor
Knowing the Point that you want to place your element on the layer ("point" in the following code snippet) you can add the Width and Height properties of your Canvas control to its X and Y values and set the Envelope property of the ElementLayer like the following:

MapPoint mapPoint1 = Map.ScreenToMap(point); // Map is your esri map control

MapPoint mapPoint2 = Map.ScreenToMap(newPoint(point.X + canvas.Width, point.Y + (or -) canvas.Height));

ElementLayer.SetEnvelope(canvas, newEnvelope(mapPoint1, mapPoint2)); // canvas is your Canvas control
0 Kudos