首页 > 解决方案 > 带有标签和标记的 Python Folium 地图

问题描述

我试图学习叶子,并试图在我的区域周围放置标记和标签。但我在第 22 行遇到错误。我无法解决这个问题。

文件“ipython-input-43-4e44e7187a3d”,第 22 行 home_map.add_child(home) ^ SyntaxError: invalid syntax

任何线索将不胜感激。

#Home with intial zoom
import numpy as np  # useful for many scientific computing in Python
import pandas as pd # primary data structure library
import folium
#define My Home's geolocation coordinates
home_latitude = 28.000000
home_longitude = 77.000000

# define the world map centered around Canada with a higher zoom level
home_map = folium.Map(location=[home_latitude, home_longitude], zoom_start=15, tiles='Stamen Terrain')

home = folium.map.FeatureGroup()

home.add_child(folium.features.CircleMarker(
            [home_latitude, home_longitude],
            radius=5, # define how big you want the circle markers to be
            color='yellow',
            fill=True,
            fill_color='blue',
            fill_opacity=0.6)

home_map.add_child(home)

#label the marker
folium.Marker([home_latitude, home_longitude], popup= 'Home').add_to(home_map)
# display world map
home_map

标签: pythonpython-3.xmapsfolium

解决方案


你忘了加一个)

home.add_child(folium.features.CircleMarker(
        [home_latitude, home_longitude],
        radius=5, # define how big you want the circle markers to be
        color='yellow',
        fill=True,
        fill_color='blue',
        fill_opacity=0.6
        ) #<= here
        )

推荐阅读