🧪 We're running a cheminformatics notebook competition!

Enter by October 4
30 / 103
Click and Zoom

Click and Zoom

by marimo team

Click and zoom into maps to explore and get coordinates back in Python.

About this notebook

This notebook connects an OpenLayers map to Python with the openlayers package. It creates a MapWidget, adds a click interaction, and wraps the widget in mo.ui.anywidget so marimo can read its state. The notebook loads no dataset: its input is the base map and your interactions with it.

The map is interactive. When you pan, zoom, or click, the widget sends the new map state to Python, and marimo re-runs every cell that reads it. One cell shows the current view of the map, and another shows the data for the last click.

The click interaction comes from a single call, m.add_click_interaction(). The MapWidget is an anywidget, and mo.ui.anywidget adapts any anywidget for marimo's reactive runtime.

Related notebooks