<jupyter_start><jupyter_text>Plugin: leaflet-search Polygon search layer<jupyter_code>import json


with open(os.path.join('data', 'search_states.json')) as f:
    states = json.loads(f.read())


def getColor(d):
    if d > 1000:
        return '#800026'
    if d > 500:
        return '#BD0026'
    if d > 200:
        return '#E31A1C'
    if d > 100:
        return '#FC4E2A'
    if d > 50:
        return '#FD8D3C'
    if d > 20:
        return '#FEB24C'
    if d > 10:
        return '#FED976'
    else:
        return '#FFEDA0'


for state in states['features']:
    state['properties']['color'] = getColor(state['properties']['density'])
from folium import plugins


m = folium.Map(
    location=[37.8, -96],
    tiles='cartodbpositron',
    zoom_start=3,
)

plugins.Search(states, search_zoom=6, geom_type='Polygon').add_to(m)

m.save(os.path.join('results', 'Plugins_search_polygon.html'))

m<jupyter_output><empty_output><jupyter_text>Points search layer<jupyter_code>m = folium.Map(
    location=[41.9, 12.5],
    tiles='cartodbpositron',
    zoom_start=12,
)


with open(os.path.join('data', 'search_bars_rome.json')) as f:
    bars = json.loads(f.read())

plugins.Search(bars, search_zoom=20).add_to(m)


m.save(os.path.join('results', 'Plugins_search_points.html'))

m<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15713196033562166, 'fraction_numerical': 0.04500381388253242, 'mean_word_length': 3.5874125874125875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '542918', 'license': 'MIT', 'n_tokens_mistral': 542, 'n_tokens_neox': 500, 'n_words': 94, 'path': 'examples/plugin-Search.ipynb', 'repo_name': 'meteoDaniel/folium', 'size': '1311'}