I have the following piece of code of my Leaflet application (Typescript):

getPolygonMarker(): GeoJSON {
    let itemShape: any = [

    const p = new Polygon(itemShape[0].coordinates);
    const latLngs = p.getLatLngs();
    const center = p.getBounds().getCenter();
    const angle = item['heading']);

    const rotatedPoints: Array<LatLng> = [];
    (latLngs[0] as Array<LatLng>).forEach((latLng) => {
        rotatedPoints.push(GeometryUtil.rotatePoint(map, latLng , angle, center));


    return geoJSON(p);



As you can see I first generate a GeoJSON starting from a wkt object and then I convert it to Polygon to be able to use GeometryUtil plugin rotatePoint method.

But I can't figure out how to convert back Polygon to GeoJSON to use it on my map. Using geoJSON(p) doesn't do the trick.

I also tried to return Polygon instead of GeoJSON in my getPolygonMarker() method and then add it to the map with addLayer, but despite I don't get any error there is no shape on my map.

Any solution or workaround?

I have already tried this solution but it doesn't work. I have also found this, but I have not tried it because I would not rotate polygon using CSS!



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.