In a forum post from December of 2010 a PITS entry was referenced regarding map shape transformations. Does anyone know what happened with this request as PITS is gone. I can find no such item in the Feedback & Feature Requests. I would like to rotate a MapPath that has, as it Data, a MapRectangleGeometry object. That object has a Transform member but when a RotateTransform is applied to it, it the resulting shape will not maintain its position as the map is zoomed.
5 Answers, 1 is accepted
0
Hello Scott,
The mentioned feature request is marked "DONE" several years ago and it is not translated from PITS into our new feedback portal. The features is basically consisted of setting the RenderTransform successfully on MapShape objects in Information Layer. In the attached project you can check RotateTransform applied on a MapPath with MapRectangleGeometry. Is it possible to modify the project so that the issue you have encountered is reproducible ? Thank you in advance for your cooperation.
Regards,
Petar Mladenov
Telerik
The mentioned feature request is marked "DONE" several years ago and it is not translated from PITS into our new feedback portal. The features is basically consisted of setting the RenderTransform successfully on MapShape objects in Information Layer. In the attached project you can check RotateTransform applied on a MapPath with MapRectangleGeometry. Is it possible to modify the project so that the issue you have encountered is reproducible ? Thank you in advance for your cooperation.
Regards,
Petar Mladenov
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0
Scott
Top achievements
Rank 1
answered on 04 May 2015, 12:59 PM
I need to rotate around the center. I am attaching an example where I have provided code to
1. Use the lat, lon for the RotateTransform for center
2. Use GetPoint to get the x, y screen points for the RotateTransform center
3, Apply either of the above to the MapPath RenderTransform property
4. Apply either of the above to the MapRectangleGeometry Transform property.
The attached file is really a zip, but this forum does not allow me to upload that.
0
Hello Scott,
Most probably the second and third argument (CenterX, CenterY) in RotateTransform constructor are based from 0, 0 - the top left corner of the object to rotate. However, this is the usual way of rotating around the center:
This works as expected on our side. Let us know if this is what you needed.
Regards,
Petar Mladenov
Telerik
Most probably the second and third argument (CenterX, CenterY) in RotateTransform constructor are based from 0, 0 - the top left corner of the object to rotate. However, this is the usual way of rotating around the center:
RotateTransform transform =
new
RotateTransform(45);
mapPath.RenderTransform = transform;
mapPath.RenderTransformOrigin =
new
Point(0.5, 0.5);
Regards,
Petar Mladenov
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0
Scott
Top achievements
Rank 1
answered on 05 May 2015, 01:17 PM
Problem is, I need to rotate around lat/lon point. I am allowing users to draw and edit shapes with a mouse and I show thumbs that must rotate with the shape. Second, I get a null reference exception if the MapPath contains MapPathGeometry with a MapPathFigure containing a MapLineSegment. Here is the sample, it has been updated to the latest controls. Once again, the attachment is really a zip file.
0
Hi Scott,
Thank you for your sample.
We managed to reproduce the exception and we logged it in our feedback portal where you can track its status. We also updated your telerik account points.
If the rotated MapPath is added in XAML the exception is not reproducible, however this might not be applicable in your scenario.
A better workaround you can consider is replacing the InformationLayer with VisualizationLayer (VL) and work with Map Shape Data Objects. Attached is your code converted to work with VL and PathData, RectangleGeometryData, PathFigureData, LineSegmentData.
Also I added a possible code for rotating the MapPinPoint. If the rotation point is *rect.Center*, you can calculate the RotateTransforms's CenterX and CenterY like so:
I hope this code is a good starting point and you will be able to use it as a base. Probably the rest of the work is some + / - (negative positive , min/max) checks and respecting the size of the pinpoint.
Regards,
Petar Mladenov
Telerik
Thank you for your sample.
We managed to reproduce the exception and we logged it in our feedback portal where you can track its status. We also updated your telerik account points.
If the rotated MapPath is added in XAML the exception is not reproducible, however this might not be applicable in your scenario.
<
telerik:InformationLayer
x:Name
=
"informationLayer"
>
<
telerik:MapPath
Stroke
=
"Black"
StrokeThickness
=
"2"
>
<
telerik:MapPath.Data
>
<
telerik:MapPathGeometry
>
<
telerik:MapPathGeometry.Figures
>
<
telerik:MapPathFigure
StartPoint
=
"38.899, -77.0145"
>
<
telerik:MapPathFigure.Segments
>
<
telerik:MapLineSegment
Point
=
"37.8174, -75.6128"
/>
</
telerik:MapPathFigure.Segments
>
</
telerik:MapPathFigure
>
</
telerik:MapPathGeometry.Figures
>
</
telerik:MapPathGeometry
>
</
telerik:MapPath.Data
>
<
telerik:MapPath.RenderTransform
>
<
RotateTransform
Angle
=
"45"
/>
</
telerik:MapPath.RenderTransform
>
</
telerik:MapPath
>
A better workaround you can consider is replacing the InformationLayer with VisualizationLayer (VL) and work with Map Shape Data Objects. Attached is your code converted to work with VL and PathData, RectangleGeometryData, PathFigureData, LineSegmentData.
Also I added a possible code for rotating the MapPinPoint. If the rotation point is *rect.Center*, you can calculate the RotateTransforms's CenterX and CenterY like so:
var center = rect.Center;
Point centerPoint = center.GetPoint(
this
.RadMap);
//A pin to represent the center.
MapPinPoint centerPin =
new
MapPinPoint() { Height = 10, Width = 10, Background = Brushes.Red };
MapLayer.SetLocation(centerPin, center);
//A pin that needs to rotate with the mapPath object
MapPinPoint cornerPin =
new
MapPinPoint() { Height = 10, Width = 10, Background = Brushes.Purple };
MapLayer.SetLocation(cornerPin, rect.Northwest);
Point cornerPinPoint = rect.Northwest.GetPoint(
this
.RadMap);
cornerPin.RenderTransform =
new
RotateTransform(45, centerPoint.X - cornerPinPoint.X, centerPoint.Y - cornerPinPoint.Y);
I hope this code is a good starting point and you will be able to use it as a base. Probably the rest of the work is some + / - (negative positive , min/max) checks and respecting the size of the pinpoint.
Regards,
Petar Mladenov
Telerik
See What's Next in App Development. Register for TelerikNEXT.