# Polygon rotation

1. ##### Yan Moura
33 posts
Member since:
Feb 2010

Posted 30 Sep 2011 Link to this post

Hello!

I am writing a SL version of an existing Flash application, whose goal is to help our employees to locate car bodies in our junkyard (we have over 1000 carcass).

Each car will be represented in the map by a rectangle (four sides polygon), and to get the actual position of each car in the yard, one of our employee captured the exact location of each one with a GPS (where the coordinate means the center axis of the car).

However, depending on the place in the junkyard, the front of the car may be pointing to a different direction.

So my question is: how to rotate a polygon? There is a method where I can enter a radian as parameter to make it rotate?

Thanks!
2. ##### Andrey
1681 posts

Posted 05 Oct 2011 Link to this post

Hi Yan Moura,

Please, find attached sample solution which demonstrates how the geographically positioned polygon can be rotated.

Greetings,
Andrey Murzov
the Telerik team

3. ##### Jimmy
24 posts
Member since:
Nov 2006

Posted 05 Oct 2011 Link to this post

How to achieve the point of aggregation, reduced to a certain level in the map, use a point with numbers to represent the point of repeating and re-amplified to a certain level, the point ofre-emerging
4. ##### Andrey
1681 posts

Posted 10 Oct 2011 Link to this post

Hi Jimmy,

I'm sorry, but I don't quite understand your question. Could you, please, elaborate a bit more on what are you trying to implement and what the problem is? A sample image demonstrating it could be very helpful too.

All the best,
Andrey Murzov
the Telerik team

5. ##### Jimmy
24 posts
Member since:
Nov 2006
6. ##### Yan Moura
33 posts
Member since:
Feb 2010

Posted 11 Oct 2011 Link to this post

Hi Andrey,

The sample application showed me exactly what I had in mind.
Thanks a LOT for this!

On another subject, can the rendered polygons be treaten as if they would independent objects and have events associated to them? I mean, they can, for instances, be clicked and dragged by the user, right-clicked, etc?

Thanks!
7. ##### Andrey
1681 posts

Posted 13 Oct 2011 Link to this post

Hello Jimmy,

It looks like the DynamicLayer could provide with functionality similar (but not the same) to the described at the given links. Please, take a look into the following demo:

http://demos.telerik.com/silverlight/#Map/DynamicLayer

Kind regards,
Andrey Murzov
the Telerik team

8. ##### Jimmy
24 posts
Member since:
Nov 2006

Posted 13 Oct 2011 Link to this post

Can this show the numbers of point???
9. ##### Yan Moura
33 posts
Member since:
Feb 2010

Posted 13 Oct 2011 Link to this post

Andrey,

Could you please give me a clue about how to control the created objects such as change its rotation or coordinate on-the-fly?

I have created a function that allows to change the rotation of the object on-the-fly by locating the object in the ObservableCollection, then saving its properties, removing the object and then recreating it with the new desired rotation.

Basically this method can be used to update any characteristic in the object, but in my opinion it has a lot of code. My question is if there is an easier and more straightforward way to do that such as just changing the desired property value?

My current code looks like this:

private void RotateObject(string id, double new_angle)
{
// 'Objects' is the InformationLayer binded ItemsSource

int zz;
for (zz = 0; zz <= this.ObjObservableCollection.Objects.Count - 1; zz++)
if (this.ObjObservableCollection.Objects[zz].ID == id)
{
// save existing data
Location loc = this.ObjObservableCollection.Objects[zz].Location;
string id = this.ObjObservableCollection.Objects[zz].ID;
LocationRect mycb = new LocationRect(new Location(north, west), new Location(north, west));
Color color = this.ObjObservableCollection.Objects[zz].Color;
double north = ObjObservableCollection.Objects[zz].North;
double west = ObjObservableCollection.Objects[zz].West;

// remove the old object
this.ObjObservableCollection.Objects.RemoveAt(zz);

// recreate the object with the new rotation angle
this.MyInformationLayer.RegionMode = RegionSizeMode.Dynamic;
this.MyInformationLayer.Region = rect;

Location loc = new Location(north,west);
CustomObject obj = new CustomObject()
{
ID = id,
Location = loc,
Fill = new SolidColorBrush(color),
Color = color,
North = north,
West = west,
RotationAngle = new_angle,
};

break;
}
}

However I was thinking if something like THIS could be done (I tried this and it didn't work):

private void RotateObject(string id, double new_angle)
{
// 'Objects' is the InformationLayer binded ItemsSource

int zz;
for (zz = 0; zz <= this.ObjObservableCollection.Objects.Count - 1; zz++)
if (this.ObjObservableCollection.Objects[zz].ID == id)
{
this.ObjObservableCollection.Objects[zz].RotationAngle = new_angle;
break;
}
}

Thanks!
10. ##### Andrey
1681 posts

Posted 18 Oct 2011 Link to this post

Hi Jimmy,

Since the item in the dynamic layer can be arbitrary framework element you can show any information in it.

Regards,
Andrey Murzov
the Telerik team

11. ##### Yan Moura
33 posts
Member since:
Feb 2010

Posted 15 Nov 2011 Link to this post

Andrey,

I revisited your sample project and noticed that there is a problem with it: the shapes don't zoom in/out together with the map. Any thoughts to solve that?

Thanks,

Yan
12. ##### Andrey
1681 posts

Posted 18 Nov 2011 Link to this post

Hi Yan Moura,

I'm sorry, but I don't quite understand your question. Could you, please, clarify which is the sample project you are talking about and what is the problem you are facing?

Best wishes,
Andrey Murzov
the Telerik team

13. ##### Yan Moura
33 posts
Member since:
Feb 2010

Posted 18 Nov 2011 Link to this post

Hi Andrey,

The project I am talking about your RotatePinPoint.zip project (that you have attached on the second post on THIS current thread at Oct 5).

The arrows created don't zoom together with the map. No matter if you are at 10,000 km or 50m height, the size of the arrows remains the same. I think that they should zoom in/out together with the map, right?

Yan
14. ##### Andrey
1681 posts

Posted 22 Nov 2011 Link to this post

Hello Yan,

No, they should not. This project uses regular Silverlight shapes which aren't affected by map zoom level. Only map shapes (like MapPolygon or MapPolyline) change its visible size when map zoom in or out. But map shapes don't support rotation transformation currently. We are planning to change it in future. You can track the status of this feature using our PITS:

http://www.telerik.com/support/pits.aspx#/public/silverlight/4404

All the best,
Andrey Murzov
the Telerik team

15. ##### Yan Moura
33 posts
Member since:
Feb 2010

Posted 22 Nov 2011 Link to this post

Hi Andrey,

Boomer!

It really would be too much more productive if polygons could be expanded and treated as independent objects within the Information Layer. It would allow you to rotate, resize, move, paint, etc, each one of them! :)

I am currently remaking a complex application that make extensive use of geographical polygons. Originally this app was done in Flash, that makes this kind of project a breeze. For instances, with Flash to rotate an existing polygon, it is just to change its angle property; but with the RadMap components -- that so far is the best approach I have to do similar stuff in SL -- I have to remove the polygon and then recreate it after to calculate each rotated point with trig functions. OK, it works, but it could be easier! ;)

Anyway, I hope that in a near future, Telerik consider to restructure the way as Map polygons are manipulated! :)

Thanks,

Yan
16. ##### Andrey
1681 posts

Posted 25 Nov 2011 Link to this post

Hi Yan Moura,

We are planning to change this in future. You can track the status of this feature using our PITS:

http://www.telerik.com/support/pits.aspx#/public/silverlight/4404

Regards,
Andrey Murzov
the Telerik team