当我在推出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);