我正在尝试在折线上获取位置,但是它不起作用

时间:2019-09-29 09:25:41

标签: android-studio

我是Android Studio的新手,我想显示数据库中位于选定多段线上的位置。如果功能条件不起作用,则为这种情况。

 public ArrayList<LatLng> getMarker() throws JSONException {
    ArrayList<LatLng> points = null;

    for (int i = 0; i < result.length (); i++) {

        JSONObject jsonObject1 = result.getJSONObject ( i );
        String lat_i = jsonObject1.getString ( "1" );
        String long_i = jsonObject1.getString ( "2" );

        Double lati = Double.parseDouble(lat_i);
        Double longi = Double.parseDouble(long_i);

        LatLng DBlocations;
        DBlocations = new LatLng(lati,longi);

        //PolylineOptions polylineOptions = new PolylineOptions ();
        //polylineOptions.getPoints ()

        if (PolyUtil.isLocationOnPath (DBlocations, poly2Points, false, 10 )) {
            LatLng output=new LatLng(lati,longi);
            points.add(output);

            Toast.makeText ( getActivity (), "Buses available on route", Toast.LENGTH_LONG ).show ();
           // ((TextView) getActivity().findViewById(R.id.textViewdetails)).setText( (CharSequence) points );
             ((TextView) getActivity().findViewById(R.id.textViewdetails)).setText(Double.valueOf (lati).toString () + "," + Double.valueOf (longi).toString ());


        }else {
            ((TextView) getActivity().findViewById(R.id.textViewdetails)).setText("No Buses on route");
        }
    }
    return points;
}

0 个答案:

没有答案