aratcliffe/Leaflet.contextmenu

Not an issue, but a request for guidance.

Closed this issue · 3 comments

I have an existing leaflet map being initialised thus:

map = L.map('tab_map', {
		zoomControl: false, // Added by Zoomslider
		zoomsliderControl: true,
		attributionControl: false,
		crs: SDTD_CRS
	}).setView([0, 0], Math.max(0, mapinfo.maxzoom - 5));

How do attach the context menu to this map?

The following code enables the default leaflet menu:

map.on('contextmenu',function(e){
    		console.log(map);
		});

but, I have no idea how to use this context menu within that environment.
Any ideas?
Thanks.

Hi, you normally instantiate the contextmenu declaratively as shown in the usage section of the docs. Are you unable to do this for some reason?

It was throwing me that I already had the map initiated, and I was trying to reference that map object with your initiation code block. It eventually dawned on me that I could carry your code (minus the instantiation code) into my own instantiation code. I was just being slow - I apologise for taking your time. And thank you for taking your time to release this - I will use it on a game-attached webmap to allow a rightclick teleport-to-position feature.
Thanks again :)

Good. I'm glad you got it working :)