This is a migrated thread and some comments may be shown as answers.

Location in Polygon

1 Answer 75 Views
Map
This is a migrated thread and some comments may be shown as answers.
Hans-Joerg
Top achievements
Rank 1
Hans-Joerg asked on 19 Jan 2011, 04:38 PM
Hello,

I wonder if there is a possibility to get all objects of an information layer which are contained within a specified polygon (geo coordinates).
There is a method "InformationLayer.GetElementsInRectangle" wich is almost what we need.

best regards

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 25 Jan 2011, 07:47 AM
Hello Hans-Joerg,

If polygon is a map shape object is visible over the map, then you can use following method to detect whether specified location is inside the shape:

private bool IsLocationInShape(MapShape shapeToTest, Location location)
{
    bool isInShape = false;
  
    IEnumerable<object> list = this.InformationLayer.GetItemsInLocation(location);
    foreach (object item in list)
    {
        MapShape shape = item as MapShape;
        if (shape != null && shape == shapeToTest)
        {
            isInShape = true;
            break;
        }
    }
  
    return isInShape;
}

Then you can loop through the list of the objects and use this method to detect whether the object location is inside the specified shape.

Best wishes,
Andrey Murzov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Map
Asked by
Hans-Joerg
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or