2016-03-23 10 views
0

SupportMapFragmentのズームレベルを設定するにはどうすればよいですか?SupportMapフラグメントセットgoogle mapsズームレベル

LatLng currentLocation = mService.getCurrentLocation(); 
    CameraPosition cameraPosition = new CameraPosition.Builder() 
      .target(currentLocation) // Sets the center of the map to the current location of the user 
      .zoom(17)     // Sets the zoom 
      .bearing(90)    // Sets the orientation of the camera to east 
      .tilt(30)     // Sets the tilt of the camera to 30 degrees 
      .build();     // Creates a CameraPosition from the builder 
    mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 

をしかし、このソリューションが動作しませんでした: 私はこの1つが提案されているロブという名前の男を買う答えのように私は、同様の質問で見つかったいくつかの回答を試してみました。だから、どのように私はSupportMapFragmentを使用することを知ってズームレベルを設定することができます。あなたの現在の場所は、このコードを試してみnullでない場合

答えて

1

それは

LatLng currentLocation = mService.getCurrentLocation(); 
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentLocation , 16); 
mMap.addMarker(new MarkerOptions().position(location).title("")); 
mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLocation)); 
mMap.animateCamera(cameraUpdate) 
+0

ThxをMustanserに動作します:)これは正常に動作 – TeachMePls

1
Marker currentMarker; 

    MarkerOptions marker = new MarkerOptions().position(new 
        LatLng(Double. 
        parseDouble(lat),Double.parseDouble(lon))).title(title); 
        marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_schoolbus)); 
        currentMarker = map.addMarker(marker); 
        currentMarker.showInfoWindow(); 
        currentMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_schoolbus)); 
        map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(Double.parseDouble(lat),Double.parseDouble(lon)), 15)); 
+0

あなたサリカありがとう:D – TeachMePls

+0

あなたは歓迎:-) –