Viren V Varasadiya
Viren V Varasadiya

Reputation: 27177

how to draw path between two location in using map box?

I want to draw path between two points. I am using flutter_map 0.10.1+1 package to include map.

I am getting points between two locations using map box api. When I draw Polyline using that points it draws straight line, instead of drawing line on road.

For example I am getting following points when I try to get points between two location:

LatLng(latitude:21.202751, longitude:72.838807)
LatLng(latitude:21.198725, longitude:72.836119)
LatLng(latitude:21.196459, longitude:72.83742)
LatLng(latitude:21.195418, longitude:72.836605)
LatLng(latitude:21.195194, longitude:72.836577)
LatLng(latitude:21.189253, longitude:72.832431)
LatLng(latitude:21.186454, longitude:72.829726)

checkout following image how I am able to draw line.

enter image description here

Upvotes: 0

Views: 1369

Answers (1)

hasan karaman
hasan karaman

Reputation: 1430

You need to specify the polylines mode type in the package you use.

 GoogleMapPolyline googleMapPolyline =
      new GoogleMapPolyline(apiKey: "yourkeyhere");

googleMapPolyline.getCoordinatesWithLocation(
        origin: LatLng(40.6782, -73.9442),
        destination: LatLng(40.6944, -73.9212),
         mode: RouteMode.driving);--->You need to set the mode type

Upvotes: 1

Related Questions