question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error in displaying the resultant map in web browser.it seems blank with zoom button and a link for leaflet in the right bottom corner

See original GitHub issue

Please add a code sample or a nbviewer link, copy-pastable if possible

# Your code here
from __future__ import print_function # this line adds compatibility to python 2
import numpy as np  # useful for many scientific computing in Python
import pandas as pd # primary data structure library
from IPython.display import display
import folium
import _json
import json

df_can = pd.read_excel(r'C:\Users\DELL\Desktop\Book1.xlsx',
                     sheet_name='Sheet1')


india_map = folium.Map(zoom_start=2,tiles='Mapbox Bright')
india_geo=r'https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json'
india_map.choropleth(
    geo_data=india_geo,
    data=df_can,
    columns=['STATE', 'COUNT'],
    key_on='feature.properties.name',
    fill_color='YlOrRd',
    fill_opacity=0.7,
    line_opacity=0.2,
    legend_name='COVID COUNT'
)
display(india_map)
india_map.save("mymap1.html")
![folium](https://user-images.githubusercontent.com/63586227/80129208-60088500-85b4-11ea-9aaa-2b996e9c248f.JPG)


Problem description

[this should explain why the current behavior is a problem and what is the expected output.]

Expected Output

Output of folium.__version__

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
CriticalWillcommented, Apr 23, 2020

@rashadkp right away, I can see you are trying to use the Mapbox Bright tile set. That tile set is no longer supported in folium unless you signup with Mapbox for an account. Be advised that your Mapbox api key will be displayed in your html and can be pirated and used by others without your knowledge which you’d be on the hook for paying for. I’d recommend signing up with Maptiler (free) that offers a much larger range of tile sets and gives fairly detailed guidance on using your chosen tile set in your code. For how I worked through a similar issue see #1284. @Conengmo walked me through it and no need to pull them away from other issues that might be pressing. If this helps please close this issue or reach out if you need further assistance. Try this:

from __future__ import print_function # this line adds compatibility to python 2
import numpy as np  # useful for many scientific computing in Python
import pandas as pd # primary data structure library
from IPython.display import display
import folium
import _json
import json
from folium import TileLayer

df_can = pd.read_excel(r'C:\Users\DELL\Desktop\Book1.xlsx',
                     sheet_name='Sheet1')


india_map = folium.Map(zoom_start=2,tiles=None)
TileLayer(tiles='https://api.maptiler.com/maps/bright/{z}/{x}/{y}@2x.png?key=HmFDBGna8Uvh3s7BdfxN',name='Base Map',
    attr='<a href=https://www.maptiler.com/copyright/>© MapTiler | </a><a href=http://www.openstreetmap.org/about/>© OpenStreetMap').add_to(map)
india_geo=r'https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json'
india_map.choropleth(
    geo_data=india_geo,
    data=df_can,
    columns=['STATE', 'COUNT'],
    key_on='feature.properties.name',
    fill_color='YlOrRd',
    fill_opacity=0.7,
    line_opacity=0.2,
    legend_name='COVID COUNT'
)
display(india_map)
india_map.save("mymap1.html")
![folium](https://user-images.githubusercontent.com/63586227/80129208-60088500-85b4-11ea-9aaa-2b996e9c248f.JPG)
0reactions
rashadkpcommented, Apr 24, 2020

@CriticalWill Thank you for the response

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet map is going blank when zooming more than 18
javascript - Leaflet map is going blank when zooming more than 18 - Stack Overflow. Stack Overflow for Teams – Start collaborating and...
Read more >
Documentation - a JavaScript library for interactive maps
Runs the given function fn when the map gets initialized with a view (center and zoom) and at least one layer, or immediately...
Read more >
Chapter 6 Leaflet | Introduction to Web Mapping
In this chapter, we will learn how to initialize a Leaflet web map on our web page, and how to add several types...
Read more >
Display problem with Leaflet map in Bootstrap accordion
The map displays perfectly in a page. It does not display properly in a bootstrap accordion when the panel first opens. The map...
Read more >
Leaflet - a JavaScript library for interactive maps - GitHub Pages
Whether the map can be zoomed by using the mouse wheel. If passed 'center' , it will zoom to the center of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found