Contextmenu support vue2leaflet
julienlz opened this issue · 2 comments
Hello,
may be if you have time, is to implement your work on Vue2leaflet
could be a good improvement
Best
If you do all your map drawing manually, say, without but with javascript, you can get Leaflet.contextmenu to work. It requires a mix of both. In the project i work on, all drawing is done manually.
First you need to start the contextmenu code, you can do this by adding the contextmenu options in the l-map definition. For example:
<l-map :options="{contextmenu: true,}">
Then you need to manually manage the map drawing process... you can do this by working with leaflet directly. You can get access to your map via this.$refs.lmap.mapObject in your vue2leaflet components script. You might also need to inject L in your component to gain access to helper functions.
This is of course by no means a solution to your question, as you want to create the menu in a declarative (component) way, which would be absolutely awesome. :)
Yes, it works with the @contextmenu
. I use it manually with the mapObject API exposed through refs.
I put the l-popup
in a l-layer-group
and then i put a ref on the layer group.
I can open the popup by calling this.$refs.myLayerGroupRef.mapObject.openPopup(<LatLng>)
.
thanks