0

I have a folium map code (python) working in a loop mode, the following code works well except that the popup insert does not work.

(database columns : "Latitude", "Longitude", "SA", "cluster-db" )

I think that the index is not correct and would like to know which one could works in my case

    import matplotlib.cm as cm
import matplotlib.colors as colors

map_clusters = folium.Map(location=[data['Latitude'].mean(), data_['Longitude'].mean()],
               tiles='CartoDB positron', zoom_start=7)

# set color scheme for the clusters
x = cluster
ys = [i + x + (i*x)**2 for i in range(len(x))]
colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]

# add markers to the map
markers_colors = []
for lat, lng, cluster in zip(data['Latitude'], data['Longitude'],  
                                            data['cluster-db']):

    folium.vector_layers.CircleMarker(
        [lat, lng],
        radius=5,
        #tooltip =  '- Cluster ' + str(cluster),
        popup = (data.iloc[lat]['Sa'], data.iloc[lat]['Latitude'], dat.iloc[lat]['Longitude']),
        color=rainbow[cluster-1],
        fill=True,
        fill_color=rainbow[cluster-1],
        fill_opacity=0.9).add_to(map_clusters)
       
map_clusters
New contributor
JEG is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

0

Your Answer

JEG is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.