开发者

Setting zoom level automatically in Google map in Android

Hi I am using Google map in Android.where I am drawing a line between two GeoPoints.I need set the zoom level dynamically as the distance between two points increases or decreases.

Waiting for your 开发者_如何学编程reply


Use zoomToSpan() on MapController. Compute the span based on the distances between your points. If your points are not centered, either take that into account (by increasing the desired span) or recenter the map.


I've found similar solution. You can use CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int padding)

Here is an example:

Builder boundsBuilder = LatLngBounds.builder();
ArrayList<LatLng> decodedPoints = (ArrayList<LatLng>) PolyUtil.decode(step);
for (LatLng point : decodedPoints) {
    boundsBuilder.include(point);
}
LatLngBounds bounds = boundsBuilder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 10);
map.moveCamera(cameraUpdate);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜