我是Android上的Google Map API的新手。我有一个默认位置,当我单击以启动Google Map时,它会以3D视图显示位置(左侧的屏幕截图),但实际上我更喜欢右侧的屏幕截图(注意:与放大倍数无关)
如何在Android中以编程方式设置偏好设置?
MapFragment mapFragment = (MapFragment)getFragmentManager().findFragmentById(R.id.map_fragment);
mMap=mapFragment.getMap();
mMap.setMyLocationEnabled(true);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mPosition, 13));
CameraUpdate zoom = CameraUpdateFactory.zoomTo(18);
mMap.animateCamera(zoom);
mMarker=mMap.addMarker(setMarkerOptions(markerTitle,markerMsg,mPosition));
mMarker.setDraggable(true);
}
private MarkerOptions setMarkerOptions(String title,String msg,LatLng position){
MarkerOptions options=new MarkerOptions();
options.title(title);
options.snippet(msg);
options.position(position);
return options;
}
我认为您打算在此处更改的是地图的倾斜度(视角)。您可以在调用之前设置零件的倾斜度mMap.animateCamera
。在Google地图的“相机和视图”文档中,该文档包含有关如何更改相机位置的信息:
改变相机位置
There are two convenience methods for the common position changes. CameraUpdateFactory.newLatLng(LatLng) gives you a CameraUpdate that changes the camera's latitude and longitude, while preserving all other properties. CameraUpdateFactory.newLatLngZoom(LatLng, float) gives you a CameraUpdate that changes the camera's latitude, longitude and zoom, while preserving all other properties.
For full flexibility in changing the camera position, use CameraUpdateFactory.newCameraPosition(CameraPosition) which gives you a CameraUpdate that moves the camera to the given position. A CameraPosition can be obtained either directly, using new CameraPosition() or with a CameraPosition.Builder using new CameraPosition.Builder().
我专门链接了该CameraPosition
对象,因为它具有允许您提供float tilt
值的构造函数。
我不完全确定这是否是唯一的方法,但是请务必仔细阅读文档,我很确定您会从那里找到所需的内容。干杯! :D
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句