在Android中居中地图标记 [英] Center a map marker in Android

查看:274
本文介绍了在Android中居中地图标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在缩放级别显示单个标记,但它不会将地图标记放在地图上。只有一个标记会显示:

I use the following code to display a single marker at a zoom level but it doesn't center tha marker on the map. Only one marker will ever be shown:

LatLng latLng = new LatLng(Latitude, Longitude);
cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 11.0f);

此代码将居中,但不提供任何缩放:

This code will center it but it doesn't provide any zoom:

LatLngBounds bounds = latLngBuilder.build();
cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 30);

我需要居中放大。

推荐答案

缩放的正确值介于2.0和22.00之间。

The correct value for zoom is between 2.0 and 22.00.

在此之后,您必须添加此行

After this you've to add this line

GoogleMap mMap;
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latlng, 10));

关于缩放,您可以从文档中阅读
zoom:所需的缩放级别范围从2.0到21.0。低于这个范围的值被设置为2.0,并且高于它的值被设置为21.0。增加值以放大。并非所有区域都有最大缩放级别的图块。

About zoom you can read this from documentation zoom: the desired zoom level, in the range of 2.0 to 21.0. Values below this range are set to 2.0, and values above it are set to 21.0. Increase the value to zoom in. Not all areas have tiles at the largest zoom levels.

您可以在 http://developer.android.com/reference/com/google/android/gms/maps/CameraUpdateFactory.html

这篇关于在Android中居中地图标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆