2016-12-14 12 views
0

我正在使用SKMaps v3.0 SDK for Android,我嘗試將用戶標題模式更改爲Rotating_Map,以便讓用戶能夠使用標題位置旋轉地圖。標題模式旋轉地圖

這裏是我的代碼:

private void followTheUserWithHeading(int transitionTime){ 
    mapView.getMapSettings().setCurrentPositionShown(true); 
    mapView.getMapSettings().setFollowPositions(true); 
    mapView.getMapSettings().setHeadingMode(SKMapSettings.SKHeadingMode.ROTATING_MAP); 
    mapView.animateToBearing(1.0f,true,transitionTime); 
    mapView.centerOnCurrentPosition(17,true,500); 
} 

隨着followTheUserWithHeading()被調用的方法onRouteCalculationCompleted。

不幸的是,地圖不會隨手機方向旋轉。

N.B. :用戶錐是可見的,當使用SKHeadingMode.ROUTE時不是這種情況。所以看起來我的代碼並不完全是廢話......我也嘗試過ROTATING_HEADING,但不是更好。

非常感謝:)

回答

0

好吧,我終於找到了解決我的問題......

這不是行人模式的問題。爲了使ROTATIN_MAP有效,您必須實施所有傳感器事件。

見進一步的細節Android的示範項目,但這裏是看代碼片段

private void setHeading(boolean enabled) { 
    if (enabled) { 
     headingOn = true; 
     mapView.getMapSettings().setHeadingMode(SKHeadingMode.ROTATING_MAP); 
     startOrientationSensor(); 
    } else { 
     headingOn = false; 
     mapView.getMapSettings().setHeadingMode(SKMapSettings.SKHeadingMode.NONE); 
     stopOrientationSensor(); 
    } 
} 

/** 
* Activates the orientation sensor 
*/ 
private void startOrientationSensor() { 
    orientationValues = new float[3]; 
    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); 
    Sensor orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); 
    sensorManager.registerListener(this, orientationSensor, SensorManager.SENSOR_DELAY_UI); 
} 

/** 
* Deactivates the orientation sensor 
*/ 
private void stopOrientationSensor() { 
    orientationValues = null; 
    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); 
    sensorManager.unregisterListener(this); 
} 
+0

我有向您提供skmaps庫相關答案。如果你想使用標題信息旋轉地圖,很明顯你需要訪問那個標題信息,並且使用傳感器來獲取。 –

1

此功能僅在行人導航中可用。只有當使用在步行者導航模式

+0

好吧,我沒有提到它,但我使用的行人導航模式,步行路線模式:) – GrayFox

3

此功能的工作(通過使用像navigationSettings.setNavigationMode(SKNavigationSettings.SKNavigationMode.PEDESTRIAN的調用)設置;) 爲了使你需要確保你調用功能。mapView.getMapSettings()setHeadingMode(SKMapSettings.SKHeadingMode.ROTATING_MAP); 導航是剛開始之後(navigationManager.startNavigation(navigationSettings);) 我附上下面顯示的工作功能的視頻: https://www.dropbox.com/s/onnsbeavldxvdpu/20161221_PedestrianNavigation_RotatingMap.mp4?dl=0