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.

Opening a popup on clicking a GeoJSON object

See original GitHub issue

From the documentation on popup, it seems like popups can only be opened interactively with the marker element.

I wonder if it can also be opened via a custom callback function attached to a GeoJSON.on_click method, adding something like popup.open() or popup.close() to the Popup class.

Seems to be related to #239. Any suggestions on how I should proceed from here?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
martinRenoucommented, Jan 13, 2022

adding something like popup.open() or popup.close() to the Popup class

That sounds like a good idea 😃

If you would like to implement this feature, I guess it will be similar to the redraw function the TileLayer class provides: https://github.com/jupyter-widgets/ipyleaflet/blob/master/ipyleaflet/leaflet.py#L589-L595 It sends a comm message asking for a redraw, and the front-end handles it here: https://github.com/jupyter-widgets/ipyleaflet/blob/3273696bfe73d051fc7864f6731c8ed2198e6f68/js/src/layers/TileLayer.js#L76-L80 Don’t hesitate to ask for more guidance 😃 Opening the popup in JS will look like the following I guess:

this.map_view.el.openPopup(this.el);  // "this.el" is the Popup object at that point
0reactions
PROgram52bccommented, Jan 18, 2022

Any comments on #914?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show popup on GeoJSON layer data when button is clicked?
Problem in your code is that your are opening popup only the first time layer is added to the map, and not subsequently...
Read more >
Leaflet open a popup on marker click from GeoJSON layer
Bind your popup when the feature is created, not when the user clicks on it, Leaflet will handle the click events for you:...
Read more >
Display a popup on click | Mapbox GL JS
When a user clicks a symbol, show a popup containing more information. ... add additional images, open the style in Mapbox Studio and...
Read more >
Map with polygon and popup from GeoJSON using JavaScript
This video shows how to load GeoJSON with polygon features from an external file with OpenLayers and how to create a popup from...
Read more >
Display a popup on click | MapLibre GL JS Docs
When a user clicks a symbol, show a Popup containing more information. ... });. // Add a layer showing the places. ... //...
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