I checked out the Google Maps API directions documentation but it just says a lot of things, can anyone show me a code on how to use the Directions API on Android?
I just want Point A to have a line direction going to Point B.
Yes it is possible to intergrate direcitons api with map. There is no need to write your own API. You can achieve this very easily. With Google android api V2 there is no need to draw canvas. Adding things in it is very easy.
Please read here for Google Maps https://developers.google.com/maps/documentation/android/start
and for directions
https://developers.google.com/maps/documentation/directions/
During the process you have any specific problem then please ask that.
Thanks,
Simple way If you know lattitude and longitude of your starting and ending point, then you can load google map with direction line in a webview.
This is the code snippet for load google map in webview.
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
myWebView.getSettings().setJavaScriptEnabled(true);
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Loading...");
progressDialog.show();
myWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
if (progressDialog.isShowing()) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
}
}, 2000);
}
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//Show error message
}
});
myWebView.loadUrl("http://maps.google.com/maps?saddr=" + latitude + "," + longitude + "&daddr=" + deignationLat + "," + deignationLong);
Or you can refer the link:http://www.journaldev.com/13373/android-google-map-drawing-route-two-points
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With