Planing route with google maps

155 views Asked by At

I need to show on Android in my app google maps and also should be a possibility planing route between two points and need the possibility to set way to travel (walking, driving).

Which package should I use?

2

There are 2 answers

1
David On

The package would be [nativescript-google-maps-sdk][1], but the docs referenced above would be very pertinent if you REALLY want to display the route within your own app. Alternatively, you could compose and open a url that would open the default maps app with the route / directions and have all the expected function there. To do this you'd use the nativescript-geolocation plugin to get the current location, and the utils.openUrl method to open the composed URL. You'll also need to use https://github.com/nathanaela/nativescript-permissions to handle requesting permission. The resulting code can look something like:

  url = "https://www.google.com/maps/dir/?api=1&origin=" + loc.latitude + "," + loc.longitude + "&destination=" + addr.replace(/ /g, "+") + "";
  utils.openUrl(url);
1
Darsh Reddy On

Use this API - https://developers.google.com/maps/documentation/directions/overview it will help in getting directions and route.