Map rendering in jupyter notebook as grey box
Whenever I try to create a basic map, the map object is created but it renders as a grey box. I've reviewed several resolved issues but in these the map was rendering but the layers were grey. In my case, just a grey box:
Fresh virtual environment with minimal packages, Mac.
UPDATE: the map is rendering correctly in JupyterLab but not in standard Notebook which is where i generally work. Same virtua env when testing both.
Thanks for reporting the issue, could you post any error message you see in the browser console?
Strange, how did you install?
You mean how did I install ipyleaflet? Via pip in a new virtual environment. Odd that it is working correctly in JypterLab but not in Notebooks when both are using the same virtual env and both are opened in chrome.
You mean how did I install ipyleaflet?
Yes, I just tried in a new environment with:
pip install ipyleaflet jupyterlab notebook
and it works fine on my side, both on Chrome.
Could you give the output of pip freeze?
Here you are:
anyio==3.2.1 appnope==0.1.2 argon2-cffi==20.1.0 async-generator==1.10 attrs==21.2.0 backcall==0.2.0 beautifulsoup4==4.9.3 bleach==3.3.0 blessings==1.7 bqplot==0.12.29 branca==0.4.2 cachetools==4.2.2 certifi==2021.5.30 cffi==1.14.5 chardet==4.0.0 click==8.0.1 click-plugins==1.1.1 cligj==0.7.2 colour==0.1.5 cycler==0.10.0 debugpy==1.3.0 decorator==5.0.9 defusedxml==0.7.1 earthengine-api==0.1.272 ee==0.2 entrypoints==0.3 ffmpeg-python==0.2.0 Fiona==1.8.20 folium==0.12.1 future==0.18.2 geeadd==0.5.5 geemap==0.8.17 geocoder==1.38.1 geopandas==0.9.0 google-api-core==1.30.0 google-api-python-client==1.12.8 google-auth==1.32.1 google-auth-httplib2==0.1.0 google-cloud-core==1.7.1 google-cloud-storage==1.40.0 google-crc32c==1.1.2 google-resumable-media==1.3.1 googleapis-common-protos==1.53.0 googledrivedownloader==0.4 greenlet==1.1.0 httplib2==0.19.1 httplib2shim==0.0.3 idna==2.10 ipyevents==0.8.2 ipyfilechooser==0.4.4 ipykernel==6.0.1 ipyleaflet==0.14.0 ipynb-py-convert==0.4.6 ipython==7.25.0 ipython-genutils==0.2.0 ipytree==0.2.1 ipywidgets==7.6.3 jedi==0.18.0 Jinja2==3.0.1 jsonschema==3.2.0 jupyter-client==6.1.12 jupyter-core==4.7.1 jupyter-server==1.9.0 jupyterlab-pygments==0.1.2 jupyterlab-widgets==1.0.0 kiwisolver==1.3.1 logzero==1.7.0 MarkupSafe==2.0.1 matplotlib==3.4.2 matplotlib-inline==0.1.2 mistune==0.8.4 mss==6.1.0 munch==2.5.0 nbclient==0.5.3 nbconvert==6.1.0 nbformat==5.1.3 nest-asyncio==1.5.1 nodejs==0.1.1 notebook==6.4.0 npm==0.1.1 numpy==1.21.0 optional-django==0.1.0 packaging==21.0 pandas==1.3.0 pandocfilters==1.4.3 parso==0.8.2 pexpect==4.8.0 pickleshare==0.7.5 Pillow==8.3.1 plotly==5.1.0 prometheus-client==0.11.0 prompt-toolkit==3.0.19 protobuf==3.17.3 ptyprocess==0.7.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycparser==2.20 PyCRS==1.0.2 Pygments==2.9.0 pyparsing==2.4.7 pyproj==3.1.0 pyrsistent==0.18.0 pyshp==2.1.3 python-box==5.3.0 python-dateutil==2.8.1 pytz==2021.1 pyzmq==22.1.0 ratelim==0.1.6 requests==2.25.1 requests-unixsocket==0.2.0 rsa==4.7.2 sankee==0.0.5 scipy==1.7.0 seaborn==0.11.1 Send2Trash==1.7.1 Shapely==1.7.1 six==1.16.0 sniffio==1.2.0 soupsieve==2.2.1 SQLAlchemy==1.4.20 tenacity==7.0.0 terminado==0.10.1 testpath==0.5.0 tornado==6.1 traitlets==5.0.5 traittypes==0.2.1 uritemplate==3.0.1 urllib3==1.26.6 voila==0.2.10 wcwidth==0.2.5 webencodings==0.5.1 websocket-client==1.1.0 whitebox==1.5.1 whiteboxgui==0.3.0 widgetsnbextension==3.5.1
You don't have JupyterLab installed?
I do, running it right now. I launch it from the Anaconda Navigator and then select the correct environment once I have a notebook open. Maybe it isn't in that list because its not installed directly in that virtual environment?
I don't know the Anaconda Navigator, but since you can run JupyterLab from outside your environment, I'm wondering if you're also not running the Notebook from outside your environment. Because re-creating your environment from what you posted, I can show a map in the Notebook without any problem. Could you try without the Anaconda Navigator, with a completely separate environment?
Ran into the same problem.
In my case the gray boxes appear as the lat/lons for the map center were being set to nonsensical values
Compare output between the two below:
map_center = (52.204793, 360.121558)
m = Map(center=map_center, zoom=8,
basemap = basemaps.OpenTopoMap)
m
map_center = (418525, 8135541, 418525, 8135541)
m = Map(center=map_center, zoom=8,
basemap = basemaps.OpenTopoMap)
m
I had (probably) the same error. The same dead grey box without any UI controls, the same browser console errors, etc.
I tried creating an empty map with:
m = Map()
m
And it displayed an empty map, suggesting the error was in the param values I was passing. Indeed, the center param I was passing was invalid. I fixed it and it solved the problem.
So I guess the problem is in the 360.121558. Please try passing latitude between -90 and +90, and longitude between -180 and +180.
For me, the Map was not displaying, unless I explictly pass zoom and center via the constructor. Previously, I was using fit_bounds like this:
map = Map(basemap=basemap=basemaps.OpenStreetMap.Mapnik)
# add layers, icons, etc. to map
map.fit_bounds(get_bounds())
which worked fine previously, but renders a grey box in the current version. Changing it to:
map = Map(center=get_center(), zoom=1.0, basemap=basemaps.OpenStreetMap.Mapnik)
# add layers, icons, etc. to map
map.fit_bounds(get_bounds())
makes the map render correctly (get_center() does not need to be the center, since the zoom and location will be set via fit_bounds, but it does need to be set to something).
Should be fixed by #1068
