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

location range within shapes

2 Answers 76 Views
Map
This is a migrated thread and some comments may be shown as answers.
Donna
Top achievements
Rank 1
Donna asked on 07 Feb 2011, 08:24 PM
Is it possible, once a shape is drawn on the map, to be able to determine any pin points that fall within the shape?

2 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Feb 2011, 10:28 AM
Hi Donna,

The information layer contains the GetElementsInRectangle method. You can use it to get pin points within the geographical bounds of the MapShape. Also you can select the pin points which are inside the shape using the InformationLayer.GetItemsInLocation method.
The sample GetPinPointsInShape method is below.
private Collection<MapPinPoint> GetPinPointsInShape(MapShape shape)
{
    Collection<MapPinPoint> points = new Collection<MapPinPoint>();

    
var shapes = this.informationLayer.GetElementsInRectangle(shape.GeographicalBounds);
    foreach (object item in shapes)
    {
        MapPinPoint point = item as MapPinPoint;
        if (point != null && this.IsLocationInShape(shape, MapLayer.GetLocation(point)))
        {
            points.Add(point);
        }
    }

    
return points;
}

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;
}

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>>
0
Donna
Top achievements
Rank 1
answered on 09 Feb 2011, 05:09 PM
This works for me. Thank you very much!
Tags
Map
Asked by
Donna
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Donna
Top achievements
Rank 1
Share this question
or