gpt4 book ai didi

android - Google Maps v2 设置缩放级别

转载 作者:IT老高 更新时间:2023-10-28 23:37:36 26 4
gpt4 key购买 nike

当我在 Android 中启动 Google map 时,它会显示整个世界。我需要更改什么才能将缩放设置为标记?这是代码。谢谢

        googlemap.getUiSettings().setZoomControlsEnabled(true);
googlemap.getUiSettings().setMyLocationButtonEnabled(true);


LatLng cameraLatLng = sfLatLng;
float cameraZoom = 17;


if(savedInstanceState != null){
mapType = savedInstanceState.getInt("map_type", GoogleMap.MAP_TYPE_NORMAL);

double savedLat = savedInstanceState.getDouble("lat");
double savedLng = savedInstanceState.getDouble("lng");
cameraLatLng = new LatLng(savedLat, savedLng);

cameraZoom = savedInstanceState.getFloat("zoom", 30);

googlemap.setMapType(mapType);
googlemap.animateCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, cameraZoom));

最佳答案

试试这个---->

  map.addMarker(new MarkerOptions().position(latlng)).setVisible(true);

// Move the camera instantly to location with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15));

// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(14), 2000, null);

关于android - Google Maps v2 设置缩放级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16998169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com