Skip to content

map does not render in jupyter with large numbers of points #1244

@jwhendy

Description

@jwhendy

This is related to the comment by @bag189 here.

I just ran into this myself, where in jupyter lab, my code execution completes, but the output cell stays empty. Using m.save(), the html output file opens fine directly in the browser.

$ pip freeze |grep folium
folium==0.10.1

$ pip freeze |grep jupyter
jupyter-client==5.3.4
jupyter-core==4.6.1
jupyterlab==1.2.4
jupyterlab-server==1.0.6

$ chromium --version
Chromium 79.0.3945.88 Arch Linux

Here is a reproducible example representative of my real-world case.

import folium
import pandas as pd
import random

n = 3100
df = pd.DataFrame({'lat': [random.uniform(25, 49) for _ in range(n)],
                   'lng': [random.uniform(-124, -67) for _ in range(n)]})

m = folium.Map(location=[39, -96], zoom_start=4)
for i, row in df.iterrows():
    p = folium.CircleMarker(
    location=[row.lat, row.lng],
    radius=3,
    stroke=False,
    fill=True,
    fill_color='#000000',
    fill_opacity=1)
    p.add_to(m)
m

Via guess and check, I found that n = 3100 will render, but using n = 3200 does not. I'm happy to open this with jupyter if you think the issue is on their side.


edit: I couldn't help myself. Looks like n = 3167 is the limit (at least on my system) that will render, n = 3168 will not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThe issue is a duplicate of a previous issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions