nativescript-google-maps-sdk icon indicating copy to clipboard operation
nativescript-google-maps-sdk copied to clipboard

Creating route between two points

Open komal2694 opened this issue 6 years ago • 7 comments

i am using nativescript-google-maps-sdk plugin.It is showing me google map and also adding marker on given point. Can anyone tell me how to draw route between two points using this plugin in typescript.

komal2694 avatar Dec 24 '17 09:12 komal2694

You can use ployline function on mapview to draw a route. in order to get route information you can use google direction api.

You need to do following steps

  1. Call google direction API, with input origin and destination
  2. Decode overview_polyline.points from response
  3. Convert decoded points to Position object
  4. Create Polyline object set width and color as you need , add positions from above steps to polyline object using addpoint function
  5. add polyline into mapview using addpolyline function on mapview

I hope this help

milansar avatar Dec 24 '17 11:12 milansar

Hello Milansar, Thank you for your valuable feedback.Using your instructions i am able to draw PolyLine between two points.But it is giving me straight line .Can you please help me to draw route between two point like google-map does.

komal2694 avatar Dec 28 '17 08:12 komal2694

@komal2694 did u find any solution ?

rAnAaRsl avatar Mar 05 '18 07:03 rAnAaRsl

@komal2694, you need to use all the points, not just two.

sntran avatar Mar 27 '18 13:03 sntran

@komal2694 can u share some sample code how you draw the polyline using nativescript-google-maps-sdk plugin.

arunkumart07 avatar Oct 27 '18 12:10 arunkumart07

How to decode these encoded polyline points?

saibbyweb avatar Jan 17 '19 10:01 saibbyweb

how to call Google Direction API? is there a function from this plugin? @sntran @milansar

paul-castro avatar Jul 02 '20 09:07 paul-castro