我有一个 MapView,我在上面调用 getController().zoomToSpan()。我对 zoomToSpan() 的问题是我希望在地图图钉之外有一个一致的(例如,15dp)填充,以便可以选择它们而无需用户捏合来缩小。目前我正在使用地图引脚的最小/最大长/纬度填充 zoomToSpan(),因此边缘上的那些不会立即可见或可选择。
我考虑过使用固定的长/纬度填充,但我不能保证地图图钉不会太近或太远。因此,虽然固定的长/纬度填充可能适用于大多数情况,但它不适用于所有情况。
这就是我当前设置 zoomToPan() 的方式:
mapView.getController().zoomToSpan(MapPoint.convertToGeoPoint(Math.abs(fMinLat - fMaxLat)), MapPoint.convertToGeoPoint(Math.abs(fMinLong - fMaxLong)));
这是我对如何设置它的一个想法,但我不确定它是否真的解决了问题,或者是否有更好的方法来做到这一点:
mapView.getController().zoomToSpan(MapPoint.convertToGeoPoint((float) (Math.abs(fMinLat-fMaxLat) + (Math.abs(fMaxLat - fMaxLat)) * 0.5)), MapPoint.convertToGeoPoint((float) (Math.abs(fMinLong-fMaxLong) + (Math.abs(fMinLong - fMaxLong) * 0.5))));
我已经检查了这些问题,但我已经过了让它工作的点;我只是想让它变得优美: zoomToSpan implementation problem和Calculating zoomToSpan() degree based on min/max lat/lng to be in the mapView。