toni_mc

Line element zoom

Discussion created by toni_mc on Oct 3, 2011
Latest reply on Oct 3, 2011 by agray1
It seems that Line element on graphic container when zoom in or out changes
it size. When line element is zoom in it becomes bigger, and zoom out it
becomes smaller. How to make line element stay fixed size after zoom?
I have tried some stuff but with no success. Here is code if someone could
give few tips.

code:

private IGeographicCoordinateSystem m_GeographicCoordinateSystem;
private IProjectedCoordinateSystem m_ProjectedCoordinateSystem;

private void MainForm_Load(object sender, EventArgs e)
{
ISpatialReferenceFactory2 spatRefFact = new SpatialReferenceEnvironmentClass();

m_GeographicCoordinateSystem = spatRefFact.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

m_ProjectedCoordinateSystem = spatRefFact.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_World_Mollweide);

}

private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.ActiveView.FocusMap;

IElement ELEMENT;
ILineElement lineElement = new LineElementClass();

IPointCollection pLinePointColl;
IPolyline pLine;

IPoint point1 = new PointClass();
IPoint point2 = new PointClass();

pLinePointColl = new PolylineClass();

point1.PutCoords(e.mapX, e.mapY);

point2.X = point1.X + 10;
point2.Y = point1.Y + 10;

point1.Project(m_ProjectedCoordinateSystem);
pLinePointColl.AddPoint(point1);

point2.Project(m_ProjectedCoordinateSystem);
pLinePointColl.AddPoint(point2);

pLine = (IPolyline)pLinePointColl;

ELEMENT = (IElement)lineElement;
ELEMENT.Geometry = pLine;

axMapControl1.ActiveView.GraphicsContainer.AddElement(ELEMENT, 0);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}

Outcomes