{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap\n", "import ipywidgets as widgets\n", "from ipyleaflet import WidgetControl" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "# Add an output widget to the map\n", "output_widget = widgets.Output(layout={\"border\": \"1px solid black\"})\n", "output_control = WidgetControl(widget=output_widget, position=\"bottomright\")\n", "Map.add_control(output_control)" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "# Capture user interaction with the map\n", "def handle_interaction(**kwargs):\n", " latlon = kwargs.get(\"coordinates\")\n", " if kwargs.get(\"type\") == \"click\":\n", " Map.default_style = {\"cursor\": \"wait\"}\n", " # xy = ee.Geometry.Point(latlon[::-1])\n", "\n", " with output_widget:\n", " output_widget.clear_output()\n", " print(latlon)\n", " Map.default_style = {\"cursor\": \"pointer\"}\n", "\n", "\n", "Map.on_interaction(handle_interaction)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }