Skip to content

Commit edb413c

Browse files
authored
Merge pull request #542 from giswqs/master
Fixed basemap name typo
2 parents 6c64a7d + e40420b commit edb413c

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

examples/DropdownControl.ipynb

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"from ipyleaflet import basemaps,basemap_to_tiles, Map, WidgetControl\n",
10+
"from ipywidgets import Dropdown"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"m = Map(center=[0, 0], zoom=2)\n",
20+
"\n",
21+
"ee_basemaps={}\n",
22+
"\n",
23+
"# Loops through all ipyleaflet basemaps\n",
24+
"for item in basemaps.values():\n",
25+
" try:\n",
26+
" name = item['name']\n",
27+
" basemap = 'basemaps.{}'.format(name)\n",
28+
" ee_basemaps[name] = basemap_to_tiles(eval(basemap))\n",
29+
" except:\n",
30+
" for sub_item in item:\n",
31+
" name = item[sub_item]['name']\n",
32+
" basemap = 'basemaps.{}'.format(name)\n",
33+
" basemap = basemap.replace('Mids', 'Modis')\n",
34+
" ee_basemaps[name] = basemap_to_tiles(eval(basemap))\n",
35+
"\n",
36+
"# Adds a Dropdown widget\n",
37+
"dropdown = Dropdown(\n",
38+
" options=list(ee_basemaps.keys()),\n",
39+
" value='OpenStreetMap.Mapnik',\n",
40+
" description='Basemaps'\n",
41+
")\n",
42+
"\n",
43+
"# Handles Dropdown control event\n",
44+
"def on_click(change):\n",
45+
" basemap_name = change['new']\n",
46+
" old_basemap = m.layers[-1]\n",
47+
" m.substitute_layer(old_basemap, ee_basemaps[basemap_name])\n",
48+
" \n",
49+
"dropdown.observe(on_click, 'value')\n",
50+
"\n",
51+
"# Adds control to the map\n",
52+
"basemap_control = WidgetControl(widget=dropdown, position='topright')\n",
53+
"m.add_control(basemap_control)\n",
54+
"\n",
55+
"m"
56+
]
57+
}
58+
],
59+
"metadata": {
60+
"kernelspec": {
61+
"display_name": "Python 3",
62+
"language": "python",
63+
"name": "python3"
64+
},
65+
"language_info": {
66+
"codemirror_mode": {
67+
"name": "ipython",
68+
"version": 3
69+
},
70+
"file_extension": ".py",
71+
"mimetype": "text/x-python",
72+
"name": "python",
73+
"nbconvert_exporter": "python",
74+
"pygments_lexer": "ipython3",
75+
"version": "3.8.2"
76+
}
77+
},
78+
"nbformat": 4,
79+
"nbformat_minor": 4
80+
}

ipyleaflet/basemaps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
url='https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Terra_CorrectedReflectance_Bands721/default/%s/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg',
136136
max_zoom=9,
137137
attribution='Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (<a href="https://earthdata.nasa.gov">ESDIS</a>) with funding provided by NASA/HQ.',
138-
name='NASAGIBS.MidsTerraBands721CR'
138+
name='NASAGIBS.ModisTerraBands721CR'
139139
),
140140
ModisAquaTrueColorCR=dict(
141141
url='https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Aqua_CorrectedReflectance_TrueColor/default/%s/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg',

0 commit comments

Comments
 (0)