How to use Google Maps Directions API for Android?

I checked the documentation on the Google Maps API API, but it just says a lot of things, can someone show me the code on how to use the Directions API on Android?

I just want point A to have a line direction going to point B.

+4
source share
2 answers

Yes, you can map api directives to a map. No need to write your own API. You can achieve this very easily. With Google android api V2 there is no need to draw a canvas. Adding things to it is very simple.

, Google https://developers.google.com/maps/documentation/android/start

https://developers.google.com/maps/documentation/directions/

- , , .

,

+1

, , google -.

google map 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);

: http://www.journaldev.com/13373/android-google-map-drawing-route-two-points

+1

Source: https://habr.com/ru/post/1679885/


All Articles