繁体   English   中英

在Android中放大MapActivity(ItemizedOverlay)中的点组

[英]Zoom into group of points in the MapActivity (ItemizedOverlay) in Android

如果希望所有POI在地图中可见,则需要动态调整两个参数:

  • 地图中心
  • 缩放步骤

我想知道MapActivity是否已内置这种行为? 如果没有,您能提供给我示例代码吗?

答案不是在一组点中找到中心点,然后调用mapController.zoomToSpan(centrePoint)。 而是在ItemizedOverlay中执行以下操作:

public void calculateMapBounds()
{       
    int minLat = Integer.MAX_VALUE;
    int minLon = Integer.MAX_VALUE;
    int maxLat = Integer.MIN_VALUE;
    int maxLon = Integer.MIN_VALUE;

    for (LocatorPosition position : mPositions)
    {
        minLat = Math.min(position.getLatitudeE6(), minLat);
        minLon = Math.min(position.getLongitudeE6(), minLon); 
        maxLat = Math.max(position.getLatitudeE6(), maxLat); 
        maxLon = Math.max(position.getLongitudeE6(), maxLon);
    }

    spanLat = maxLat - minLat;
    spanLon = maxLon - minLon;

}

然后调用mapController.zoomToSpan(spanLat,spanLon);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM