Python - Folium 的搜索插件出错

Python - Search Plugin of Folium give an error

我在 python.However 中使用 folium.Search() ,代码 returns 当我 运行 我的 code.How 解决这个问题时出现错误?

import folium
from folium import plugins    
import json


m = folium.Map(location=[39.92370048 , 32.85271525],zoom_start=12)    
with open('3596566.json') as f:    
    data = json.load(f)

plugins.Search(data,position='topright',                  
               search_zoom=20,
               search_label='ParselNo',
               geom_type="Polygon").add_to(m)

m.save('map.html')

错误是:

Traceback (most recent call last):
  File "C:/Users/HP/proje/ödev2.py", line 17, in <module>
    geom_type="Polygon").add_to(m)

  File "C:\Python36\lib\site-packages\folium\plugins\search.py", line 100, in __init__
    ), 'Search can only index FeatureGroup, ' \

AssertionError: Search can only index FeatureGroup, MarkerCluster, GeoJson, and TopoJson layers at this time.

我修复了此错误,因为 follows.I 将 GeoJson 文件传输到变量。

points ={
  "type": "FeatureCollection",
  "features": [
{
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          32.73684,
          39.85925
        ],
        [
          32.73575,
          39.85949
        ],
        [
          32.73573,
          39.85952
        ],
        [
          32.73574,
          39.85954
        ],
        [
          32.73574,
          39.85955
        ],
        [
          32.73576,
          39.85969
        ],
        [
          32.73576,
          39.85984
        ],
        [
          32.73582,
          39.8599
        ],
        [
          32.73695,
          39.86009
        ],
        [
          32.73701,
          39.86006
        ],
        [
          32.73701,
          39.85968
        ],
        [
          32.73701,
          39.85966
        ],
        [
          32.7369,
          39.85928
        ],
        [
          32.73684,
          39.85925
        ]
      ]
    ]
  },
  "properties": {
    "ParselNo": 1,
    "Alan": "7,384.59",
    "Mevkii": "",
    "Nitelik": "Arsa - sağlık alanı",
    "Ada": 29685,
    "Il": "Ankara",
    "Ilce": "Çankaya",
    "Pafta": "",
    "Mahalle": "Lodumu (me)"
  }
}
]}

geojson_obj = folium.GeoJson(points).add_to(m)

plugins.Search(geojson_obj,position='topleft',
                           search_zoom=17,
                           search_label='ParselNo',
                           geom_type='Polygon').add_to(m)