我是Skobbler map
的全新產品。在我的Skobbler map
中,我正在使用onCurrentPositionUpdate
方法獲取當前位置。位置從特定位置立即更改爲我在Skobbler地圖中的當前位置
SKCoordinateRegion region = new SKCoordinateRegion();
region.setCenter(currentPosition.getCoordinate());
region.setZoomLevel(13);
mapView.changeMapVisibleRegion(region, true);
因此,它顯示我的當前位置。
當我通過拖動地圖這樣的移動從我目前的位置有一定距離:
但是,很少有4或5個幾秒鐘之後,它返回到我目前的立即定位。可以做些什麼來阻止這種移動,因爲我只想在按下按鈕後返回到當前位置。在我的按鈕,我使用:
@OnClick(R.id.fab_gps)
public void goToMyGpsLocation(View view) {
if (mapView != null && currentPosition != null) {
mapView.getMapSettings().setCurrentPositionShown(true);
} else{
if(Helper.isGPSEnabled(this)){
requestCurrentPositionProvider();
}else{
Helper.alertbox("GPS not enabled", "Please enable gps before you are directed to your current location", this);
}
}
}
在我requestCurrentPositionProvider
方法:
public void requestCurrentPositionProvider(){
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
Permissions.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
Manifest.permission.ACCESS_FINE_LOCATION, true);
} else{
if(mapView != null) {
mapView.getMapSettings().setCurrentPositionShown(true);
}
if(Helper.isGPSEnabled(this)){
showSnackBar(findViewById(android.R.id.content));
currentPositionProvider = new SKCurrentPositionProvider(this);
currentPositionProvider.setCurrentPositionListener(this);
currentPositionProvider.requestLocationUpdates(MapUtils.hasGpsModule(this), MapUtils.hasNetworkModule(this), false);
}
else {
Helper.alertbox("GPS not enabled", "Please enable gps before you are directed to your current location", this);
}
喜歡的東西Camera
運動變化如此之快。我如何阻止? onClick
方法可以做些什麼,以便在按下按鈕後返回當前位置?
我在哪裏使用它?在'onCreate'或某處。 –
mapView.changeMapVisibleRegion(region,true);在此代碼下面添加它 – raasesh
無法解析animateCamera方法。我現在能做什麼 ? –