Note that there are some explanatory texts on larger screens.

plurals
  1. POleaflet geojson contextmenu
    primarykey
    data
    text
    <p>I want to add a context menu on right click for various elements on my geojson layer (I'm doing a road map so on a right click on the road at any part I want to show the context menu).</p> <p>I've managed to get the left click working fine by using the onEachFeature and doing the following</p> <pre><code>function onEachFeature(feature, layer) { layer.on({ click: showAssetInfo, contextmenu: contextreg }); } function showAssetInfo(e) { AssetMouseClick(e.target.feature.properties.objectid, e.latlng); } </code></pre> <p>For the context menu I have followed the example <a href="http://jsfiddle.net/Q3L4c/12/" rel="nofollow">here</a> . The context menu library is found <a href="http://medialize.github.com/jQuery-contextMenu/" rel="nofollow">here</a></p> <p>I have the following that gets called on the document ready (jquery)</p> <pre><code>$.contextMenu({ selector: 'path.leaflet-clickable', zIndex: 99999, callback: function (key, options) { var m = "clicked: " + key; window.console &amp;&amp; console.log(m) || alert(m); }, items: { "edit": { name: "Edit", icon: "edit" }, "cut": { name: "Cut", icon: "cut" }, "copy": { name: "Copy", icon: "copy" }, "paste": { name: "Paste", icon: "paste" }, "delete": { name: "Delete", icon: "delete" }, "sep1": "---------", "quit": { name: "Quit", icon: "quit" } } }); </code></pre> <p>I've tested it and the selector does return the GeoJson features, also if it attach the same menu to something else it works correctly.</p> <p>Is there something I am missing here?</p> <p>Also is there a good way to pass in the objectid to the menu when it starts up so I can use it when calling the different options of the menu</p> <p>EDIT: </p> <p>I have created this fiddle to demonstrate <a href="http://jsfiddle.net/Q3L4c/22/" rel="nofollow">http://jsfiddle.net/Q3L4c/22/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload