2014-04-08 55 views

回答

1

嘗試使用的GroundOverlay您的視野,這個示例使用的圖像來顯示FOV:

private GroundOverlay mFovOverlay; 
//** create the FOV **// 
private void createFov(LatLng userPosition, GoogleMap map, float bearing) { 

    GroundOverlayOptions fov = new GroundOverlayOptions();    
    fov.position(userPosition, 100f); 
    fov.anchor(0.5f, 1f); 
    fov.image(BitmapDescriptorFactory.fromResource(R.drawable.fov));     
    fov.bearing(bearing); 
    mFovOverlay = map.addGroundOverlay(fov); 

} 

//** change the FOV direction **// 
private void changeFovDirection(float bearing) { 
    fovOverlay.setBearing(bearing); 
} 

如果您想根據設備的方向改變FOV方向離子,以度爲單位調用changeFovDirection。這裏的軸承是可以從設備傳感器獲得的方位角(見What is the alternative to android orientation sensor?)。請注意,從弧度(傳感器單元),以度(的GroundOverlay軸承單元)進行轉換,這是onSensorChanged方法我的代碼段:

float azimut = orientation[0]; // orientation contains: azimut, pitch and roll 
float azimutDegrees = (float) (azimut * 180/Math.PI); 
mapFragment.changeFovDirection(azimutDegrees); 
相關問題