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. 

Read this also: How to Draw Route Direction Polylines on Google Map in Flutter

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. 

PolylinePoints polylinePoints = PolylinePoints();
LatLng startLocation = LatLng(27.6683619, 85.3101895);  
LatLng endLocation = LatLng(27.6688312, 85.3077329); 
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
    PointLatLng(startLocation.latitude, startLocation.longitude),
    PointLatLng(endLocation.latitude, endLocation.longitude),
    travelMode: TravelMode.driving,

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 get this issue.

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

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

Enable these APIS to get polylines from Direction API. Be sure you have enabled both Map SDK for Android and iOS.

Another reason might be that you haven't activated Billing on the 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...