4

I have an assignment which requires me to make an itinerary on Colaboratory using Folium. I have 8 different locations in Europe linked together with a Polyline. I was trying to make the line dashed but couldn't find a way to...

I am a beginner and couldn't find many solutions. The ones i've tried did not work, i have tried things like adding: linestyle='dashed'(i have no idea if that is what i am supposed to do or if i used it correctly, i must have just added it after color='red', --> check script part 1)

Here is my script (it was too long for one picture) Script part 1 Script part 2

Here is my map (the red lines are what i tried to get dashed)

My map

My map

Mustafa
  • 977
  • 3
  • 12
  • 25
s13ve
  • 43
  • 1
  • 4

1 Answers1

12

You can use dash_array argument in PolyLine() function:

import folium

m = folium.Map(location=[43, 11],
               zoom_start=5)

loc = [(43, 11),
       (48, 13),
       (49, 3),
       (44, 4),
       (45, 6)]

folium.PolyLine(loc,
                color='red',
                dash_array='10').add_to(m)

m

and you get:

enter image description here

sentence
  • 8,213
  • 4
  • 31
  • 40