Skip to content

Instantly share code, notes, and snippets.

@omar-3
Created September 4, 2020 18:07
Show Gist options
  • Save omar-3/e2b6c011c613725c14914e9534b847f0 to your computer and use it in GitHub Desktop.
Save omar-3/e2b6c011c613725c14914e9534b847f0 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from time import sleep\n",
"from ipyleaflet import *\n",
"\n",
"m = Map(center=(52, 10), zoom=8, basemap=basemaps.Hydda.Full)\n",
"\n",
"mark = Marker(location=(51.5, 10))\n",
"m.add_layer(mark)\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"nb_steps = 10\n",
"step = 0.1\n",
"start_location = mark.location\n",
"end_location = (52.2, 10)\n",
"\n",
"for i in range(nb_steps + 1):\n",
" percentage_animation = i / nb_steps\n",
" \n",
" a = 1 - percentage_animation\n",
" b = percentage_animation\n",
" \n",
" mark.location = (a * start_location[0] + b * end_location[0], a * start_location[1] + b * end_location[1])\n",
" \n",
" sleep(step)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment