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

Polygon rotation

15 Answers 116 Views
Map
This is a migrated thread and some comments may be shown as answers.
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Yan Moura asked on 30 Sep 2011, 06:42 PM
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!

15 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 05 Oct 2011, 02:21 PM
Hi Yan Moura,

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

Greetings,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jimmy
Top achievements
Rank 1
answered on 05 Oct 2011, 03:08 PM
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
0
Andrey
Telerik team
answered on 10 Oct 2011, 09:49 AM
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

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jimmy
Top achievements
Rank 1
answered on 11 Oct 2011, 02:53 AM
0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 11 Oct 2011, 04:25 PM
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!
0
Andrey
Telerik team
answered on 13 Oct 2011, 10:59 AM
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

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jimmy
Top achievements
Rank 1
answered on 13 Oct 2011, 12:19 PM
Can this show the numbers of point???
0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 13 Oct 2011, 09:33 PM
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,
        };

            this.ObjObservableCollection.Objects.Add(obj);
            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!
0
Andrey
Telerik team
answered on 18 Oct 2011, 08:35 AM
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

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 15 Nov 2011, 05:30 PM
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
0
Andrey
Telerik team
answered on 18 Nov 2011, 10:20 AM
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

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 18 Nov 2011, 11:19 AM
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
0
Andrey
Telerik team
answered on 22 Nov 2011, 10:44 AM
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

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 22 Nov 2011, 03:11 PM
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
0
Andrey
Telerik team
answered on 25 Nov 2011, 01:42 PM
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

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Map
Asked by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Answers by
Andrey
Telerik team
Jimmy
Top achievements
Rank 1
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Share this question
or