Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在两个拉长点之间画线?_Android_Google Maps_Path_Google Polyline - Fatal编程技术网

Android 如何在两个拉长点之间画线?

Android 如何在两个拉长点之间画线?,android,google-maps,path,google-polyline,Android,Google Maps,Path,Google Polyline,使用多段线,我可以在两点之间创建路径 但当我使用这两点时 艾哈迈达巴德到纽约 不创建多段线。 否则,如果两点之间没有海,它就会起作用 当分数是这样的时候,我就有问题了 但在这种情况下,它的工作从布吉到艾哈迈达巴德 你可以像下面这样画 PolylineOptions rectOptions = new PolylineOptions(); LatLng polLatLng = null; if (points.size() > 0) { ArrayList&

使用多段线,我可以在两点之间创建路径

但当我使用这两点时 艾哈迈达巴德到纽约 不创建多段线。 否则,如果两点之间没有海,它就会起作用

当分数是这样的时候,我就有问题了

但在这种情况下,它的工作从布吉到艾哈迈达巴德

你可以像下面这样画

 PolylineOptions rectOptions = new PolylineOptions();
    LatLng polLatLng = null;
    if (points.size() > 0) {
        ArrayList<LatLng> pathPoint = new ArrayList<LatLng>();
        for (int k = 0; k < points.size(); k++) {
            double polLat = points.get(k).latitude;
            double polLng = points.get(k).longitude;
            pathPoint.add(new LatLng(polLat, polLng));
            polLatLng = new LatLng(polLat, polLng);
        }
        double startLatitude = points.get(0).latitude;
        double startLongitude = points.get(0).longitude;
        double endLatitude = points.get(points.size() - 1).latitude;
        double endLongitude = points.get(points.size() - 1).longitude;
        LatLng start = new LatLng(startLatitude, startLongitude);
        LatLng end = new LatLng(endLatitude, endLongitude);

        mMap.addMarker(new MarkerOptions().position(start).title("start"));
        mMap.addMarker(new MarkerOptions().position(end).title("end"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(polLatLng));
        mMap.animateCamera(CameraUpdateFactory.zoomTo(10));
        rectOptions.addAll(pathPoint);
        rectOptions.width(10);
        rectOptions.color(Color.BLUE);
        mMap.addPolyline(rectOptions);

你可以像下面一样画

 PolylineOptions rectOptions = new PolylineOptions();
    LatLng polLatLng = null;
    if (points.size() > 0) {
        ArrayList<LatLng> pathPoint = new ArrayList<LatLng>();
        for (int k = 0; k < points.size(); k++) {
            double polLat = points.get(k).latitude;
            double polLng = points.get(k).longitude;
            pathPoint.add(new LatLng(polLat, polLng));
            polLatLng = new LatLng(polLat, polLng);
        }
        double startLatitude = points.get(0).latitude;
        double startLongitude = points.get(0).longitude;
        double endLatitude = points.get(points.size() - 1).latitude;
        double endLongitude = points.get(points.size() - 1).longitude;
        LatLng start = new LatLng(startLatitude, startLongitude);
        LatLng end = new LatLng(endLatitude, endLongitude);

        mMap.addMarker(new MarkerOptions().position(start).title("start"));
        mMap.addMarker(new MarkerOptions().position(end).title("end"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(polLatLng));
        mMap.animateCamera(CameraUpdateFactory.zoomTo(10));
        rectOptions.addAll(pathPoint);
        rectOptions.width(10);
        rectOptions.color(Color.BLUE);
        mMap.addPolyline(rectOptions);

最后,我得到了Ola和Uber应用程序是如何实现这些功能的答案


最后,我得到了Ola和Uber应用程序是如何实现这些功能的答案


类型=驾驶或步行兄弟使用22.970385、72.577455和41.029469、-77.618526和绘制路径。。您将无法获得输出。。首先尝试一下。然后告诉metype=driving或walkingbrother使用22.970385、72.577455和41.029469、-77.618526并绘制路径。。您将无法获得输出。。先试试……然后告诉我你在工作。我已经试过你的代码了。如果需要其他东西,请告诉我。这也不起作用。我已经试过你的代码了。如果还需要别的东西,请告诉我。
ArrayList<LatLng> points = new ArrayList<LatLng>();
                PolylineOptions polyLineOptions = new PolylineOptions();
                points.add(new LatLng(from_latitude,from_longitude));
                points.add(new LatLng(to_latitude,to_longitude));
                polyLineOptions.width(7 * 1);
                polyLineOptions.geodesic(true);
                polyLineOptions.color(activity.getResources().getColor(R.color.black));
                polyLineOptions.addAll(points);
                Polyline polyline = mMap.addPolyline(polyLineOptions);
                polyline.setGeodesic(true);