question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add on_click to Marker objects

See original GitHub issue

I tried out the new MarkerCluster capability in 0.5.3, and it works great in my notebook here: https://gist.github.com/anonymous/d414d59e50e57e23436adba70fd48b35 but I’m struggling a bit with the interaction. [BTW, this notebook should run anywhere, as it uses only web services to aquire data]

I was originally plotting markers using geoJSON, and the interaction I’m looking for is to return the name of the marker to python when I click on it. In cell [13], with geoJSON, I use feature_layer.on_click to specifying printing the name of the marker below the plot. This works great:

2017-12-19_14-51-54

I would like to do the same in cell [15], using MarkerCluster, but I cannot figure out how to get the name of the marker back on click: 2017-12-19_14-53-27

There is no feature_layer.on_click for MarkerCluster, and I guess that make sense since I really just need interaction with the individual Marker objects, right?

But the Marker objects don’t seem to have on_click either. Would it be on_trait_change?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
martinRenoucommented, Dec 19, 2018

I just tried it on the binder (last version of ipyleaflet) and on_move seems to work. Do you mind giving me an example so that I can replicate your issue? EDIT: That’s what I tried:

def handle_move(*args, **kwargs):
    print("Hey!")

my_marker.on_move(handle_move)
1reaction
kralevacommented, Oct 11, 2021

Maybe you should extend the official page documentation, by mentioning there also, that the on_click method exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marker in leaflet, click event - Stack Overflow
The accepted answer is correct. However, I needed a little bit more clarity, so in case someone else does too: Leaflet allows events...
Read more >
Add an event listener on a Marker in Leaflet
Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a...
Read more >
Simple Click Events | Maps JavaScript API - Google Developers
This example demonstrates the use of event listeners. It. listens for the click event on a marker to zoom the map when the...
Read more >
Handling Clicks on a Marker | GEOG 863: Mashups
We will add a handler for the click event that will open an info window and display ... The marker is added to...
Read more >
Support for onClick event on Markers or Layer #5 - GitHub
append (df_points.loc[point]) # store the data in a plasma in-memory object store (using pyarrow) client.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found