Android的:在谷歌地图设置缩放级别包括所有标记点 [英] Android: Setting Zoom Level in Google Maps to include all Marker points

查看:715
本文介绍了Android的:在谷歌地图设置缩放级别包括所有标记点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样的,它包括在我的列表中所有点的android设置缩放级别的地图。我使用下面的code。

I am trying to set zoom level for Maps in android such that it includes all the points in my list. I am using following code.

int minLatitude = Integer.MAX_VALUE;
int maxLatitude = Integer.MIN_VALUE;
int minLongitude = Integer.MAX_VALUE;
int maxLongitude = Integer.MIN_VALUE;

// Find the boundaries of the item set
// item contains a list of GeoPoints
for (GeoPoint item : items) { 
    int lat = item.getLatitudeE6();
    int lon = item.getLongitudeE6();

    maxLatitude = Math.max(lat, maxLatitude);
    minLatitude = Math.min(lat, minLatitude);
    maxLongitude = Math.max(lon, maxLongitude);
    minLongitude = Math.min(lon, minLongitude);
}
objMapController.zoomToSpan(
    Math.abs(maxLatitude - minLatitude), 
    Math.abs(maxLongitude - minLongitude));

这个工程的时候。但有时某些点不显示,我需要再缩小查看这些点。请问有什么办法可以解决这个问题呢?

this works sometimes. However sometimes some points are not shown and I need to then Zoom Out to view those points. Is there any way to solve this problem?

推荐答案

我找到了自己的答案,缩放级别是正确的。我需要添加以下code在屏幕上显示的所有问题。

I found out the answer myself, the Zoom level was correct. I need to add following code to display all points on screen.

objMapController.animateTo(new GeoPoint( 
    (maxLatitude + minLatitude)/2, 
    (maxLongitude + minLongitude)/2 )); 

中心点没有属性格式排列对我产生的问题。这工作。

The center point was not propery aligned creating problem for me. This works.

这篇关于Android的:在谷歌地图设置缩放级别包括所有标记点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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