Home > Mobile >  Maps in Jupyter. Naming locations
Maps in Jupyter. Naming locations

Time:08-10

I'm trying to give two different names to both locations using count:

location 1 location 2

What am I doing wrong?

import folium as fo
map = fo.Map(location=[29.76,-95.36], zoom_start=6, tiles="Stamen Terrain")
            
for coordinates in [[29.76,-95.36], [29.75,-95.34]]:
    count = 1
    fg.add_child(fo.Marker(location=coordinates, popup=f"Main Location {count}", icon=fo.Icon(color='green')))
    count = count   1
        
map.add_child(fg)

locatin

CodePudding user response:

For each loop turn you reset count to 1.

Consider :

  • initializing count outside of the loop
  • using enumerate on your list
# Not working
for coordinates in [[29.76,-95.36], [29.75,-95.34]]:
    count = 1
    print(count)
    count = count   1
​
> 1
> 1

# Working
for index, coordinates in enumerate([[29.76,-95.36], [29.75,-95.34]]):
    print(index   1)
​
> 1
> 2
  • Related