2014-04-08 26 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); 
相关问题