Use polyline in google-maps-react?

Viewed 8770

I am using google-maps-react in my react program.
Is there any way to draw polyline between the plotted markers
any in-bulid method to make line between the markers

2 Answers

yes you can all you need to do is add the points to your path inside the options.

<Polyline   geodesic={true}
            options={{
                path: props.route,
                strokeColor: '#00ffff',
                strokeOpacity: 1,
                strokeWeight: 6,
                icons: [{
                    offset: '0',
                    repeat: '10px'
                }],
            }}
 />

where props.route looks something like this

[   
    {"lat": 3.028846373870724, "lng": 101.62019493865353},
    {"lat": 3.0293392107899226, "lng": 101.62000181960445},
    {"lat": 3.0297677644503347, "lng": 101.61980870055538},
    {"lat": 3.0301963179410842, "lng": 101.61967995452267},
    {"lat": 3.0307105819060256, "lng": 101.6194868354736},
    {"lat": 3.0319319578431805, "lng": 101.61916497039181}
]
Related