0

我想开发一个 Android 应用程序,在谷歌地图上跟踪我的路线。这可能吗?如果是,请告诉我 API 是什么以及任何示例代码链接?

4

1 回答 1

-1

按照此链接 Google Maps Android:如何绘制路线以查看方向并保存所有纬度经度值以跟踪位置。

使用 api 获取方向

"http://maps.googleapis.com/maps/api/directions/json?"
                + "origin=" + start.latitude + "," + start.longitude
                + "&destination=" + end.latitude + "," + end.longitude
                + "&sensor=false&units=metric&mode=driving";

或者

如果您只想跟踪位置,请使用

public void onLocationChanged(Location location) {
        if (lastLocationloc == null) { 
               lastLocationloc = location;
           }
        //public void setPoints (List<LatLng> points)
         LatLng LatLng_origin = new LatLng( 13.133333, 78.133333); //kolar
         LatLng LatLng3 = new LatLng(21.4949767, 86.942657999);   // bbsr
        TextView tvLocation = (TextView) findViewById(R.id.add);
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
        LatLng latLng = new LatLng(latitude, longitude);
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(10));

        tvLocation.setText("Latitude:" + latitude + ", Longitude:" + longitude);


    }

还有疑问吗??

于 2013-11-04T11:42:56.760 回答