3 Answers, 1 is accepted
0
Hi Esther,
If ellipse is a map shape object (MapEllipse) which is visible over the map, then you can use following method to detect whether specified location is inside the shape:
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.
Kind regards,
Andrey Murzov
the Telerik team
If ellipse is a map shape object (MapEllipse) which 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.
Kind regards,
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
Esther
Top achievements
Rank 1
answered on 26 Jan 2011, 12:01 PM
Thanks for the reply.
The problem that I have now is that when I get the list of elements of the information layer, they are MapPinPoints and it fails when I do the cast to MapShape. TryCast returns Nothing. This is my code:
The problem that I have now is that when I get the list of elements of the information layer, they are MapPinPoints and it fails when I do the cast to MapShape. TryCast returns Nothing. This is my code:
Private Function pr__IsLocationInShape(ByVal shapeToTest As MapShape, ByVal location As Location) As Boolean Dim isInShape As Boolean = False Try Dim list As IEnumerable(Of Object) = Me.m_c_marker_layer.GetItemsInLocation(location) For Each item As Object In list Dim shape As MapShape = TryCast(item, MapShape) If shape IsNot Nothing AndAlso shape.Equals(shapeToTest) Then isInShape = True Exit For End If Next Return isInShape Catch ex As Exception Return False End Try End Function0
Accepted
Hello Esther,
It is the expected behavior. My C# and your VB.NET code looks for the MapShape object in the information layer. The information layer can contain objects of different types. If item from the layer can be casted to the MapShape the result will not be Nothing (null in C#) and we will be able to compare it with given map shape. Otherwise we just check next item.
As I've mentioned alredy the map shape object (MapEllipse) must be visible over the map. If you use 2 layers (one for pin points and second for ellipse), then you should call GetItemsInLocation method for the layer which contains MapEllipse (or other shape).
All the best,
Andrey Murzov
the Telerik team
It is the expected behavior. My C# and your VB.NET code looks for the MapShape object in the information layer. The information layer can contain objects of different types. If item from the layer can be casted to the MapShape the result will not be Nothing (null in C#) and we will be able to compare it with given map shape. Otherwise we just check next item.
As I've mentioned alredy the map shape object (MapEllipse) must be visible over the map. If you use 2 layers (one for pin points and second for ellipse), then you should call GetItemsInLocation method for the layer which contains MapEllipse (or other shape).
All the best,
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>>