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 am using ArcGIS WPF's Polyline to plot several lines (PointCollections). Adding a Path(PointCollection) looks something like this.

PointCollection collection = new PointCollection();
PolyLine myLine = new PolyLine();

collection.Add(firstMapPoint);
collection.Add(secondMapPoint);

myLine.Paths.Add(collection);

PolyLine is a Geometry in which I can set to a Graphic and plot on a map. Once that Graphic is clicked it of course is clicking the entire graphic. I am visually showing several Paths(PointCollections). Is it possible to figure out which Path is being clicked on from the user?

Note

I have a solution now where I just have 1 PointCollection per PolyLine. So I am adding one PolyLine/Graphic for each line. I would rather not do this if I can avoid it.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you have one Path per Polyline you can do something like this:

private void map1_MouseClick(object sender, Map.MouseEventArgs e)
{
            if (map1.Layers["MyGraphicsLayer"] is GraphicsLayer)
            {
                GraphicsLayer glayer = (GraphicsLayer)map1.Layers["MyGraphicsLayer"];
                IEnumerable<Graphic> graphics = glayer.FindGraphicsInHostCoordinates(map1.MapToScreen(e.MapPoint));

                foreach (var graphic in graphics)
                {
                //Do stuff
                }
             }
}

But if you want to use several Paths per Polyline I guess you have to look at catching the polyline that gets clicked and split that polyline into several polylines and use the GeometryService to do some relation operations on these.

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.