aratcliffe / Leaflet.contextmenu

A context menu for Leaflet.
MIT License
368 stars 107 forks source link

Contextmenu support vue2leaflet #124

Closed julienlz closed 5 years ago

julienlz commented 5 years ago

Hello, may be if you have time, is to implement your work on Vue2leaflet

https://github.com/KoRiGaN/Vue2Leaflet/issues/360

could be a good improvement

Best

stitch commented 5 years ago

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. :)

julienlz commented 5 years ago

Yes, it works with the @contextmenu. I use it manually with the mapObject API exposed through refs.

I put the l-popupin 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