Skip to content

run_layer_method not working with multiple args for ui.leaflet #3954

Closed Answered by falkoschindler
AIBappa asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AIBappa,

This line should work:

map.run_layer_method(m.id, ':on', '"click"', 'function(e) { alert(`Clicked at ${e.latlng.lat}, ${e.latlng.lng}`); }')
  • We don't need the f-string here, because the string interpolation happens in JavaScript on the client.
  • Without an f-string we need to replace {{ and }} with { and }.
  • Because ":on" indicates dynamic arguments that will be translated from strings to JavaScript objects on the client, the name "click" needs to be a quoted string. Otherwise JavaScript will look for an object called click, causing an error in the developer console.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AIBappa
Comment options

Answer selected by AIBappa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants