Google地图:以编程方式在地图上设置视角

安托万·默里恩(Antoine Murion)

我是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;
}

在此处输入图片说明

AL。

我认为您打算在此处更改的是地图的倾斜度(视角)您可以在调用之前设置零件的倾斜度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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

以编程方式在Google地图上添加“在Google Maps上查看”自定义按钮

来自分类Dev

在Google地图上设置路线动画

来自分类Dev

在不同大小的Google地图上设置边界

来自分类Dev

在Google地图上设置路线动画

来自分类Dev

以编程方式为传单地图上的标记提供数据属性

来自分类Dev

在地图上设置属性

来自分类Dev

Google地图上的铁路

来自分类Dev

如何在新的Google地图上设置默认缩放级别?

来自分类Dev

如何在新的Google地图上设置默认缩放级别?

来自分类Dev

如何使用Ajax在Google地图上设置标记?

来自分类Dev

使用Javascript在Google地图上设置国家/地区名称的样式

来自分类Dev

我们可以以编程方式缓存Google地图吗?

来自分类Dev

单击时以编程方式关闭 Google 地图 POI

来自分类Dev

在Google地图上添加图标

来自分类Dev

Google地图上的多个标记

来自分类Dev

在Google地图上绘制圆弧

来自分类Dev

在Google地图上保存路线

来自分类Dev

Google地图上的多个标记

来自分类Dev

在Google地图上叠加DIV

来自分类Dev

Google地图上的CAP警报

来自分类Dev

清除Google地图上的标记?

来自分类Dev

Google地图上的透明布局

来自分类Dev

在Google地图上放置文字

来自分类Dev

通过加入最外面的标记以编程方式在地图上绘制多边形

来自分类Dev

必应地图如何在地图上设置图钉(URL)?

来自分类Dev

如何在Google地图上显示项目,类似于Google显示结果的方式

来自分类Dev

当Google地图上的缩放比例> 13时,直径或绘图方式会偏离

来自分类Dev

Google地图上的信息窗口在地图加载之前

来自分类Dev

在Google地图上显示PinPoint并在“活动”中显示地图

Related 相关文章

热门标签

归档