Leaflet.contextmenu icon indicating copy to clipboard operation
Leaflet.contextmenu copied to clipboard

Does it work with angular?

Open patricia-martinez-imatia opened this issue 5 years ago • 2 comments

Does This library work with angular? I saw examples with angularjs but none with angular.

If so, there is an example to follow.

Thanks you

Yes, it works as most (if not all) js libraries. But I didn't found any dedicated support for now.

Azbesciak avatar Jul 27 '19 20:07 Azbesciak

Found solution on my own. Where I import 'leaflet-contextmenu', I manually added the type definition called leaflet-contextmenu.d.ts with the following content:

declare namespace L {
    interface ContextMenuItem {
        text: string;
        index?: number
        callback?: (ev: ContextMenuItemClickEvent) => void;
    }

    interface MapOptions {
        contextmenu: boolean;
        contextmenuItems: ContextMenuItem[]
    }

    interface MarkerOptions {
        contextmenu: boolean;
        contextmenuItems: ContextMenuItem[]
    }

    interface ContextMenuItemClickEvent {
        latlng: LatLng;
        layerPoint: Point;
        containerPoint: Point;
        relatedTarget: Marker | Path | undefined;
    }
}

Now, I am able to declare those options, compile and the plugin works. Tested in react with TS, it should work with Angular too.

joshting avatar Apr 01 '23 06:04 joshting