[英]How do I use Google Maps Directions API on Android?
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? 我查看了Google Maps API说明文档,但它只是说了很多内容,有人可以向我展示如何在Android上使用Directions API的代码吗?
I just want Point A to have a line direction going to Point B. 我只想让A点的线方向转到B点。
Yes it is possible to intergrate direcitons api with map. 是的,可以将direcitons api与地图集成。 There is no need to write your own API.
无需编写自己的API。 You can achieve this very easily.
你可以很容易地实现这一目标。 With Google android api V2 there is no need to draw canvas.
使用Google android api V2,无需绘制画布。 Adding things in it is very easy.
添加内容非常简单。
Please read here for Google Maps https://developers.google.com/maps/documentation/android/start 请在此处阅读Google地图https://developers.google.com/maps/documentation/android/start
and for directions 和方向
https://developers.google.com/maps/documentation/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. 简单方法如果您知道起点和终点的纬度和经度,则可以在webview中加载带有方向线的谷歌地图。
This is the code snippet for load google map in webview. 这是在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 或者您可以参考链接: http : //www.journaldev.com/13373/android-google-map-drawing-route-two-points
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.