{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/gee-community/geemap/blob/master/examples/notebooks/128_add_widget.ipynb)\n", "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/geemap-binder)\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 -U geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "import geemap" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "Add text." ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "text = \"Hello World\"\n", "m.add_text(text, position=\"bottomright\")\n", "m" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "Customize text style." ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "text = \"Hello World\"\n", "\n", "params = {\n", " \"fontsize\": 30,\n", " \"fontcolor\": \"blue\",\n", " \"bold\": True,\n", " \"padding\": \"10px\",\n", " \"background\": True,\n", " \"bg_color\": \"white\",\n", " \"border_radius\": \"5px\",\n", " \"position\": \"bottomright\",\n", "}\n", "\n", "m.add_text(text, **params)\n", "m" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "Add image." ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "image = \"https://i.imgur.com/LmTETPX.png\"\n", "m.add_image(image, position=\"bottomright\")\n", "m" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "Add HTML." ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "html = \"\"\"\n", "

Jupyter Logo

\n", "\n", "\"\"\"\n", "m.add_html(html, position=\"bottomright\")\n", "m" ] }, { "cell_type": "markdown", "id": "11", "metadata": {}, "source": [ "Add widget." ] }, { "cell_type": "code", "execution_count": null, "id": "12", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "id": "13", "metadata": {}, "outputs": [], "source": [ "# Data for plotting\n", "t = np.arange(0.0, 2.0, 0.01)\n", "s = 1 + np.sin(2 * np.pi * t)\n", "\n", "fig, ax = plt.subplots(figsize=(4, 3))\n", "ax.plot(t, s)\n", "\n", "ax.set(\n", " xlabel=\"time (s)\", ylabel=\"voltage (mV)\", title=\"About as simple as it gets, folks\"\n", ")\n", "ax.grid()" ] }, { "cell_type": "code", "execution_count": null, "id": "14", "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "m.add_widget(fig, position=\"bottomright\")\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }