Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to know if the IPoint of the mouse position is hitting an IPolyline, I wrote this code, and was optimistic that it would work, but it always returns false.

  IPolyline poly1 = pc1 as IPolyline;

        IHitTest test = poly1 as IHitTest;
        if (test != null)
        {
            int a = 0;
            int b = 0;
            bool c = false;
            double distance = 0;
            IPoint hitPoint = new PointClass();
            bool isHit = test.HitTest(mousepoint,
                                    50000,
                                    esriGeometryHitPartType.esriGeometryPartNone,
                                    hitPoint,
                                    ref distance,
                                    ref a, ref b, ref c);


        }
share|improve this question

1 Answer 1

up vote 2 down vote accepted

I think you should probably not use esriGeometryHitPartType.esriGeometryPartNone, but choose a geometry part which you want to test.

In your case that would probably be esriGeometryHitPartType.esriGeometryPartBoundary, which means anywhere on the polyline.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.