JavaScript Get Leaflet marker options by Leaflet ContextMenu leaflet marker options r,leaflet marker options example,leaflet marker

I try to use ContextMenu to run DeleteMaker function, but ContextMenu just get marker current Latlng, not like other leaflet events like "click", "dblclick" ... what can get marker options info.

Example :

var marker = new customMarker([28.63278, 77.21972],{
    clickable: true,
    name: 'Connaught Place',
    type: 'Neighbourhood'
    }).on('click', onClick).addTo(map);

function onClick(e) {
$('#content').html("
    Name: "+this.options.name+"
    Type: "+this.options.type+"
">;")
}

that code above can get Options value with event "click", HOW CAN I GET options value LIKE THIS WITH CONTEXTMENU

Answer:1

If you want to get marker options from outer, simply use variable name to get there.

marker.options.name
marker.options.type

See example in JSFiddle. Is this what you asked?

Answer:2

I'm using the context menu plugin for leaflet (https://github.com/aratcliffe/Leaflet.contextmenu) and I noticed the same situation. What I did was to use the "contextmenu" option for the marker event to create a global variable with the marker.options.id when a right click is detected. Then, using the context menu callback function, use that global variable (that has the marker id), fetch the marker associated to that id and THEN remove the marker from the markers array. Yes, I use a markers array because is easier to work when you have thousand of markers in the map.

It's not elegant but it works.

Answer:3

I have a component that I need to re-mount. I need to destroy everything and make it's code re-execute to appear again on my page. What I've tried: I put key="1" and then with javascript changed its ...

I have a component that I need to re-mount. I need to destroy everything and make it's code re-execute to appear again on my page. What I've tried: I put key="1" and then with javascript changed its ...

  1. reactjs remount component

Well, I'm using object orientation in JavaScript, but instead of using new, I just call the method from the namespace. In the moment, I have the following code: var Component = { Button: function(...

Well, I'm using object orientation in JavaScript, but instead of using new, I just call the method from the namespace. In the moment, I have the following code: var Component = { Button: function(...

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode ...

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode ...

  1. reverse order of characters in excel
  2. reverse order of characters
  3. reverse order of characters in a string java
  4. reverse order of characters in c
  5. excel reverse order of characters in a cell
  6. reverse the order of characters in a string c++

I was looking after region based code folding for javascript files in eclipse. The only thing I could find so far was Coffee Bytes Code Folding which extends the editor folding settings in eclipse....

I was looking after region based code folding for javascript files in eclipse. The only thing I could find so far was Coffee Bytes Code Folding which extends the editor folding settings in eclipse....

  1. javascript code folding
  2. vscode javascript code folding
  3. eclipse javascript code folding
  4. eclipse javascript code folding not working
  5. visual studio code javascript folding