设置在谷歌最大缩放级别映射机器人API第2版 [英] Setting max zoom level in google maps android api v2
问题描述
我目前正在使用谷歌开发应用程序的Android地图API第2版。 我的code是如下。 假设图有几个标记和放大为显示所有标记的显示。
I'm currently working on developing apps by using Google maps android API v2. My code is as follows. Suppose map has several markers and zoom up to show all markers in display.
LatLngBuilder.Builder builder = LatLngBounds.builder();
for(Marker m : markers){
builder.include(m.getPosition());
}
LatLngBounds bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10);
这code为工作正常,但我想停下来时,变焦倍数达到17.0f动画; 它似乎地图API不会有这样的方法来控制的缩放级别。 有谁知道任何想法来解决这个问题呢?
This code is working fine but I want to stop animating when the zoom level reached to 17.0f; It seems map API does not have such method to control zoom level. Does anybody know any idea to solve this problem?
推荐答案
我还没有发现的谷歌地图API中的任何直接的解决方案。一个潜在的解决这个问题在于听力对<一href="https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.OnCameraChangeListener">OnCameraChange事件:每当这个事件触发和缩放级别高于最大缩放级别,就可以调用<一个href="https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap#animateCamera%28com.google.android.gms.maps.CameraUpdate%29">animateCamera().由此产生的code将以下内容:
I have not found any direct solution in the Google Maps API. A potential solution to this problem consists in listening against the OnCameraChange event: Whenever this event triggers and the zoom level is above the maximum zoom level, it is possible to call animateCamera(). The resulting code would be the following:
@Override
public void onCameraChange(CameraPosition position) {
float maxZoom = 17.0f;
if (position.zoom > maxZoom)
map_.animateCamera(CameraUpdateFactory.zoomTo(maxZoom));
}
这篇关于设置在谷歌最大缩放级别映射机器人API第2版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!