I have some markers, which are polygons (squares). I am importing these from some other files and am calculating their coordinates. Now they don't fit 100% and sometimes they need to be resized and rotated a bit.
My plan was to iterate through polygons, translate their latlng point paths to local coordinates, do the rotation on local coordinates and translate them all back to latlng and aply them to marker polygon paths.
Problem is this:
PointLatLng point = new PointLatLng(15, 15);
GPoint pointLocal = MainMap.FromLatLngToLocal(point);
PointLatLng originalPoint = MainMap.FromLocalToLatLng(pointLocal.X, pointLocal.Y);
//their values are:
//point => {Lat=13, Lng=15}
//pointLocal => {X=18175317,Y=15554996}
//originalPoint => {Lat=74,4712712901167, Lng=179,999989271164}
Why is this happening, why are the final values different than the originals? How should I do the conversion properly?
As a workaround to this issue I tried rotating the LatLngs directly doing it like this:
double lng_ = Math.Cos(angle) * (point.Lng  center.Lng)  Math.Sin(angle) * (point.Lat  center.Lat) + center.Lng;
double lat_ = Math.Sin(angle) * (point.Lng  center.Lng) + Math.Cos(angle) * (point.Lat  center.Lat) + center.Lat;
marker.Polygon[i] = new PointLatLng(lat_, lng_);
But the results are not really squares anymore because the rotation somehow deformed them. (See the rotated "squares" in the left part of the image compared to the nonrotated perfect squares on the right). Is it because I'm doing calculations with
LatLng degrees or am I calculating it wrong?
Radioman, any advice?
