How to Solve Poly Line Not Drawing on Google Map Flutter

Are you displaying polyline drawings on google maps in the Flutter app to show navigation routes between two locations (longitudes and latitude) points? But, the polyline routes or road marking is not displaying then see the reason below and learn to fix it. 

We have installed flutter_polyline_points Flutter package on our dependency, and the code looks like below to fetch polyline points from Google Map API. 

PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
    PointLatLng(startLocation.latitude, startLocation.longitude),
    PointLatLng(endLocation.latitude, endLocation.longitude),
    travelMode: TravelMode.driving,
    wayPoints: [PolylineWayPoint(location: "Garden of Dreams")]

print("my points");

The output of print() function in the above code looks like below:

I/flutter (29839): my points                                            
I/flutter (29839): [] 

Here [ ] means, result.points have no items inside this list. If your output looks like this, be sure that you are not getting polyline points from Google Map API.

There may be a different reason that you are not getting these points, among them, these three reasons mentioned below may getting this issue.

1. Google Map API is not configured correctly.

If the map is displaying but not polylines then this is not the reason that is causing the issue. If you haven't known to integrate Google Map in Flutter then read the following guides and follow the steps. 

Read: How to Add Google Map in Flutter | Step by Step Easy Guide

2. Enable Directions API in Google Cloud Console.

The polyline points are provided by Directions API of Google Map Platform. Go to "Google Maps Platform" > "API" > Directions API and enable it. 

3. Activate Billing on Google Cloud Platform

Another reason might be this one that you haven't activated Billing on Google Cloud Platform yet. Give your billing details to activate premium products of Google Maps.


In this way, you can get polyline points from Google Map API. After this, your app will get all poly points between two locations and will start drawing. 

No any Comments on this Article

Please Wait...