Folium - Map doesnt appear

2024/10/7 20:33:21

I try to get map through Folium but only thing I can see is marker on blank page. I'd like to know where is problem lies, in explorer or coding.

map.py

import foliummap = folium.Map(location = [46.20, 6.144], zoom_start=6, tiles="Mapbox Bright")fg = folium.FeatureGroup(name="My Map")
fg.add_child(folium.Marker(location=[40.12, 10.1], popup="Hi I'am a Marker", 
icon=folium.Icon(color='green')))
map.add_child(fg)map.save("Map1.html")
Answer

There is a problem with the tiles name "Mapbox Bright". It seems that this kind of tiles is not supported by Folium/Leaflet anymore (without token). If you use one of the other tiles that are listed in the documentation, it will work :

import foliumm = folium.Map(location = [46.20, 6.144], zoom_start=6, tiles="OpenStreetMap")fg = folium.FeatureGroup(name="My Map")
fg.add_child(folium.Marker(location=[40.12, 10.1], popup="Hi I'am a Marker", 
icon=folium.Icon(color='green')))
m.add_child(fg)
m

It is better not to use map for the name of your map because it is a Python function and you are shadowing it (so you can't use it anymore).

https://en.xdnf.cn/q/118783.html

Related Q&A

python tkinter exe built with cx_Freeze for windows wont show GUI

PROBLEM SOLVED. the issue was with jaraco module, that i used for clipboard manipulation, i used pyperclip instead.I made a python app with tkinter that works fine, but I wanted to make an exe from it …

lxml tree connection and properties

I have a .dtsx file so, I have multiple components with connections, so I need to extract component that have especific connection, but I can not handle that, example: <components><component r…

Python recursive function call with if statement

I have a question regarding function-calls using if-statements and recursion. I am a bit confused because python seems to jump into the if statements block even if my function returns "False"…

How can I list all 1st row values in an Excel spreadsheet using OpenPyXL?

Using the OpenPyXL module with Python 3.5, I was able to figure out how many columns there are in a spreadsheet with:In [1]: sheet.max_column Out [1]: 4Then I was able to list the values in each of the…

Using matplotlib on non-0 MPI rank causes QXcbConnection: Could not connect to display

I have written a program that uses mpi4py to do some job (making an array) in the node of rank 0 in the following code. Then it makes another array in the node of rank 1. Then I plot both the arrays. T…

ioerror errno 13 permission denied: C:\\pagefile.sys

Below is my code, what I am trying to achieve is walking through the OS generating a MD5 hash of every file the code is functional, however, I receive the error in the title "ioerror errno 13 perm…

How can PyUSB be understood? [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

Resize image in python without using resize() - nearest neighbor

For an assignment I want to resize a .jpg image with a python code, but without using the pil.image.resize() function or another similar function. I want to write the code myself but I cant figure out …

Concatenate two dataframes based on no of rows

I have two dataframes:a b c d e f 2 4 6 6 7 1 4 7 9 9 5 87 9 65 8 2Now I want to create a new dataframe like this:a b c d e f 2 4 6 6 7 1 4 7 9 9 5 8 That is, I only want the rows of the …

Having Problems with AzureChatOpenAI()

people. Im trying to use the AzureChatOpenAI(), but even if I put the right parameters, it doesnt work. Here it is: from langchain_core.messages import HumanMessage from langchain_openai import AzureCh…