{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import json\n", "\n", "from ipyleaflet import AwesomeIcon, Marker, Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "markers = []" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with open(\"./bars.json\", \"r\") as fobj:\n", " bars = json.load(fobj)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for feature in bars[\"features\"]:\n", " symbol = feature[\"properties\"][\"marker-symbol\"]\n", " coords = feature[\"geometry\"][\"coordinates\"]\n", "\n", " icon = AwesomeIcon(name=symbol, marker_color=\"red\" if symbol == \"bus\" else \"blue\")\n", " markers.append(Marker(icon=icon, location=(coords[1], coords[0])))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = Map(center=(38.91342738235981, -77.03912909142674), zoom=13)\n", "\n", "for marker in markers:\n", " m += marker\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "markers[0].icon = AwesomeIcon(\n", " name=\"spinner\", marker_color=\"green\", icon_color=\"darkgreen\", spin=True\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.5" } }, "nbformat": 4, "nbformat_minor": 4 }