1

I am using the following code to display folium map:

import folium

map_hooray = folium.Map(location=[51.5074, 0.1278], zoom_start = 11) 
map_hooray 

Using the above code the map gets displayed perfectly.

But when I am trying to display the map inside a function call, the map is not getting displayed:

import folium

def map_call(a, b):
    print(a,b) ## prints 51.5074 0.1278
    
    map_hooray = folium.Map(location=[a, b], zoom_start = 11) 
    map_hooray # Calls the map to display but map is not getting displayed

map_call(51.5074, 0.1278)

Can someone please let me know how to resolve this issue.

2 Answers 2

1

Use the return statement

def map_call(a, b):
    print(a,b) ## prints 51.5074 0.1278  
   map_hooray = folium.Map(location=[a, b], zoom_start = 11) 
   return map_hooray 

map_call(51.5074, 0.1278)

enter image description here

1
  • 1
    Thanks your solution worked for me.
    – RRSC NGP
    Apr 23, 2021 at 7:00
1

Another way to go about it, is to simply use the display function. By this way, you can continue writing further script in the same cell.

Use display(map_hooray) within the function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.