{ "cells": [ { "cell_type": "markdown", "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, "metadata": {}, "outputs": [], "source": [ "# !pip install -U geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add text." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "text = 'Hello World'\n", "m.add_text(text, position='bottomright')\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Customize text style." ] }, { "cell_type": "code", "execution_count": null, "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", "metadata": {}, "source": [ "Add image." ] }, { "cell_type": "code", "execution_count": null, "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", "metadata": {}, "source": [ "Add HTML." ] }, { "cell_type": "code", "execution_count": null, "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", "metadata": {}, "source": [ "Add widget." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "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, "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 }