【发布时间】:2016-12-26 11:08:07
【问题描述】:
您好,我正在使用带有LocationListener 的谷歌地图。我可以使用 Fused API
protected void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(1000 * 60 * 1);
mLocationRequest.setFastestInterval(1000 * 60 * 1);
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
我在这里画了路径:
public void onLocationChanged(Location location) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
routePoints.add(latLng);
Polyline route = mGoogleMap.addPolyline(new PolylineOptions()
.width(5)
.color(Color.BLUE)
.geodesic(false)
.zIndex(3));
route.setPoints(routePoints);
}
关键是,无论LocationRequest的间隔时间如何,我都需要在用户移动时绘制实时路径,并在用户停止时停止。
【问题讨论】:
标签: android google-maps