10

The title says it all : I can't get Spyder to display a map with folium.

Here is what I get :

import folium
m = folium.Map(location=[45.5236, -122.6750])
m

No error (and no map), just this :

< folium.folium.Map at 0xd03fcf8 >

m.render() # No idea what .render() it's supposed to do, 
# but "render" sounds like maybe it could display the map, so I tried it.
# But it prints nothing

m.render

< bound method LegacyMap.render of < folium.folium.Map object at 0x000000000D03FCF8 > >

Any idea ?

Thanks

(Note : I tried this, with no success)

François M.
  • 4,027
  • 11
  • 30
  • 81
  • This link may help: https://stackoverflow.com/questions/36969991/folium-map-not-displaying/38797877#38797877 – Alwan Sep 11 '18 at 20:16

3 Answers3

14

If you have a map m you could use:

m.save("mymap.html")

It saves your map in your working directory as html. You still have to open it manually in Chrome/IE. The advantage of this is that you can e-mail your map to anyone you want, even if he/she does not have python on his/her computer.

Dadep
  • 2,796
  • 5
  • 27
  • 40
Dick van Huizen
  • 161
  • 1
  • 5
3

It seems folium generates web based maps, and those can't be rendered by Spyder. So you need to use the Jupyter notebook if you want to work with folium.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
3

Also open the map directly from the spyder ide by importing webbrowser(provided you've install the webbrowser package).


import webbrwoser
webbrowser.open_tab("map.html")

  • ```webbrowser.open_new_tab('test.html')``` as of May 18, 2023. also, ```webbrowser``` is an embedded package in Python (no need to install it) – Manuel F May 18 '23 at 10:02