Topic: Drawing multiple lines with Google API

Hey there,

Here's some sample code of mine. I'm only seeing only line shown on my map whereas there should be 50.

Cheers,

    private void DrawPersonalLinks()
    {
        List<Vector2> points = new List<Vector2>();

        foreach (SentimentMarker sentimentMarker in _sentimentMarkers)
        {
            points.Clear();
            points.Add(_yourLocationStaticMapMarker.position);
            points.Add(sentimentMarker.position);
               
            OnlineMapsDrawingLine line = new OnlineMapsDrawingLine(points, Color.white);

            // Draw the line route on the map.
            OnlineMaps.instance.AddDrawingElement(line);
        }
    }

Re: Drawing multiple lines with Google API

Hello.

In your case, you have 50 identical lines.
Move «List <Vector2> points = new List <Vector2> ();» inside the foreach.

foreach (SentimentMarker sentimentMarker in _sentimentMarkers)
{
    List<Vector2> points = new List<Vector2>();
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.