谷歌地图v2设置缩放级别 [英] Google Maps v2 Set Zoom Level

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

问题描述

当我在推出Android版谷歌地图,它显示了整个世界。我需要什么改变,以便设置缩放到标记?下面是codeS。谢谢

  googlemap.getUiSettings()setZoomControlsEnabled(真)。
    googlemap.getUiSettings()setMyLocationButtonEnabled(真)。
    经纬度cameraLatLng = sfLatLng;
    浮cameraZoom = 17;
    如果(savedInstanceState!= NULL){
        地图类型= savedInstanceState.getInt(map_type,GoogleMap.MAP_TYPE_NORMAL);        双savedLat = savedInstanceState.getDouble(纬度);
        双savedLng = savedInstanceState.getDouble(LNG);
        cameraLatLng =新的经纬度(savedLat,savedLng);        cameraZoom = savedInstanceState.getFloat(放大,30);        googlemap.setMapType(地图类型);
        googlemap.animateCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng,cameraZoom));


解决方案

试试这个---->

  map.addMarker(。新的MarkerOptions()位置(经纬度))调用setVisible(真)。  //瞬间移动相机的位置为15的缩放。
  map.moveCamera(CameraUpdateFactory.newLatLngZoom(经纬度,15));  //放大,动画摄像机。
  map.animateCamera(CameraUpdateFactory.zoomTo(14),2000,NULL);

When I launch Google maps in Android, it shows the whole world. What do i need to change so as to set the zoom to the marker? Here are the codes. Thanks

        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));

解决方案

try this---->

  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);

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

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