你好,我正在使用谷歌地圖LocationListener
。我能點之間繪製路徑中使用融合APIAndroid谷歌地圖在移動時繪製路徑
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
。
謝謝你,但我想沒有時間間隔我的意思是畫線,而用戶後,移動不是一個方法間隔,由於電池問題,我不能使它間隔很小。我只想在用戶移動時使用一個程序。 – Radwa
@Radwa請注意'locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,1,myLocationListener);'這並不意味着它在每秒意味着它被調用,差異需要至少1秒和1米的通話該方法再次。如果位置不再更改它永遠不會被調用更多 –
我得到你的想法我的問題是我做了間隔1分鐘它繪製的路徑,但忽略點我檢查在不到分鐘即如果我檢查在A,然後轉到B,然後C從點A畫到點C忽略點b,因爲它不到分鐘 – Radwa