Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get leafmap maps in the documentation rendering from a jupyter notebook in mkdocs? #516

Closed
bgriffen opened this issue Aug 21, 2023 · 2 comments
Labels
Feature Request New feature or request

Comments

@bgriffen
Copy link

bgriffen commented Aug 21, 2023

Description

I am trying to create my own mkdocs page and all is running well. I then wanted to render the leafmap maps from the Jupyter notebooks exactly as it is here. I thought by lifting the relevant parts of the mkdocs yaml config for leafmap thinking I would be able to render Jupyter notebooks but not having any success. The text/code blocks update but no map renders.

Source code

mkdocs.yml:

plugins:
    - search
    - mkdocstrings
    - mkdocs-jupyter:
          include_source: True
          ignore_h1_titles: True
          execute: True
          include_requirejs: true
          allow_errors: false
          ignore: ["conf.py"]
          execute_ignore:
              [
                  "*.ipynb",
              ]

Just starting with even a basic notebook import/display as follows:

leafmap

My result on my mkdocs page as such:

result

Was there additional things in the mkdocs.yml that I'm missing or something else to get the map to display? I tried the other feature request in 2021 related to this but didn't lead anywhere. Any help appreciated. Thank you.

@bgriffen bgriffen added the Feature Request New feature or request label Aug 21, 2023
@giswqs
Copy link
Member

giswqs commented Aug 21, 2023

Unfortunately, I don't think mkdocs-jupyter supports rendering ipywidgets. See danielfrg/mkdocs-jupyter#67. The mkdocs-jupyter maintainer never responded to the request, so I closed it.

For the leafmap mkdocs, I use folium to render it. See
https://github.com/opengeos/leafmap/blob/master/leafmap/__init__.py#L22

@giswqs giswqs closed this as completed Aug 21, 2023
@prncevince
Copy link

prncevince commented Sep 10, 2023

Was scratching my head on this a bit as well but this issue/question clarified things. Thank you.

Also, a helpful resource here is understanding how to select from the different backends of Leafmap.

For the solution above make sure that the environment variable is set before importing leafmap:

import os
os.environ['USE_MKDOCS'] = 'True'
import leafmap
m = leafmap.Map()
m

Or you can select & set the folium backend directly:

import leafmap.foliumap
m2 = leafmap.foliumap.Map()
m2

We get the same results for both. And renders nicely as quarto html output as well.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants