0

我正在开发一个与 Android Place Locator 相关的应用程序,我一直在努力显示位置(许多位置和自己的位置),但我想显示任意两个位置之间的路径。位置可以是任意两个。工作了很多,但没有找到任何解决方案。请给我一些参考,以便我得到解决方案。

4

2 回答 2

0
try this code   


   String uri = "http://maps.google.com/maps?saddr=" +
   currentLatitude+","+currentLongitude+"&daddr="+fixedLatitude+","+fixedLongitude;
   Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
   Uri.parse(uri)); intent.setClassName("com.google.android.apps.maps",
   "com.google.android.maps.MapsActivity"); startActivity(intent);

愿这对你有帮助

于 2013-01-02T09:57:20.560 回答
0

要添加此库,请在 gradle 中添加依赖项为

compile 'com.akexorcist:googledirectionlibrary:1.0.4'

在活动中使用此代码

GoogleDirection.withServerKey("YOUR_SERVER_API_KEY")
            .from(new LatLng(37.7681994, -122.444538))
                .to(new LatLng(37.7749003,-122.4034934))
                .avoid(AvoidType.FERRIES)
                .avoid(AvoidType.HIGHWAYS)
                .execute(new DirectionCallback() {
        @Override
        public void onDirectionSuccess(Direction direction, String rawBody) {
            if(direction.isOK()) {
                // Do something
Snackbar.make(btnRequestDirection, "Success with status : " + direction.getStatus(), Snackbar.LENGTH_SHORT).show();
              googleMap.addMarker(new MarkerOptions().position(origin));
            googleMap.addMarker(new MarkerOptions().position(destination));

            ArrayList<LatLng> directionPositionList = direction.getRouteList().get(0).getLegList().get(0).getDirectionPoint();
            googleMap.addPolyline(DirectionConverter.createPolyline(this, directionPositionList, 5, Color.RED));

        }

            } else {
                // Do something
            }
        }

        @Override
        public void onDirectionFailure(Throwable t) {
            // Do something
        }
    });

它会帮助你,它会帮助我

于 2017-07-21T07:23:46.507 回答