nativescript-google-maps-sdk
nativescript-google-maps-sdk copied to clipboard
Creating route between two points
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.
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
- Call google direction API, with input origin and destination
- Decode overview_polyline.points from response
- Convert decoded points to Position object
- Create Polyline object set width and color as you need , add positions from above steps to polyline object using addpoint function
- add polyline into mapview using addpolyline function on mapview
I hope this help
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 did u find any solution ?
@komal2694, you need to use all the points, not just two.
@komal2694 can u share some sample code how you draw the polyline using nativescript-google-maps-sdk plugin.
How to decode these encoded polyline points?
how to call Google Direction API? is there a function from this plugin? @sntran @milansar