Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Folium map not displaying

Running on canopy version 1.5.5.3123 With;

Folium Version: 0.1.2, Build: 1

The following code;

import folium  
import pandas as pd
LDN_COORDINATES = (51.5074, 0.1278)  
from IPython.display import HTML
import shapefile
#create empty map zoomed in on London
LDN_COORDINATES = (51.5074, 0.1278) 
map = folium.Map(location=LDN_COORDINATES, zoom_start=12)
display(map)  

Returns

<folium.folium.Map at 0x10c01ae10>

But nothing else.

How do i get to display a map within an ipython notebook?

like image 340
mapping dom Avatar asked May 01 '16 17:05

mapping dom


2 Answers

You can also save the map as html and then open it with webbrowser.

import folium
import webbrowser


class Map:
    def __init__(self, center, zoom_start):
        self.center = center
        self.zoom_start = zoom_start
    
    def showMap(self):
        #Create the map
        my_map = folium.Map(location = self.center, zoom_start = self.zoom_start)

        #Display the map
        my_map.save("map.html")
        webbrowser.open("map.html")


#Define coordinates of where we want to center our map
coords = [51.5074, 0.1278]
map = Map(center = coords, zoom_start = 13)
map.showMap()
like image 115
Pedrinho Avatar answered Sep 24 '22 11:09

Pedrinho


_build_map() doesn't exist anymore. The following code worked for me

import folium
from IPython.display import display
LDN_COORDINATES = (51.5074, 0.1278)
myMap = folium.Map(location=LDN_COORDINATES, zoom_start=12)
display(myMap)
like image 20
Shehan Ishanka Avatar answered Sep 25 '22 11:09

Shehan Ishanka