I would like to rotate polygon on Z-direction. Please See below image.
I got code from below post
Google Maps API rotate Rectangle
Which is working perfectly fine to rotate polygon on X-->Y or Y-->X direction. Please see below image.
I apologize for my English to explain this problem. I appreciate any help on this.
The following example demonstrates how to rotate a polygon.
Create a polygon from a rectangle object and display it on the map instead of rectangle.
Rotate a polygon.
check Investigation results on SO docs for code snippet
Fiddle - https://jsfiddle.net/vo0yzp2t/1/
function rotatePolygon(polygon,angle) {
var map = polygon.getMap();
var prj = map.getProjection();
var origin = prj.fromLatLngToPoint(polygon.getPath().getAt(0)); //rotate around first point
var coords = polygon.getPath().getArray().map(function(latLng){
var point = prj.fromLatLngToPoint(latLng);
var rotatedLatLng = prj.fromPointToLatLng(rotatePoint(point,origin,angle));
return {lat: rotatedLatLng.lat(), lng: rotatedLatLng.lng()};
});
polygon.setPath(coords);
}
And you can also refer to When I rotate a rectangle, it's no longer rectangular.