2016-03-23 13 views
0

Wie kann ich die Zoomstufe eines SupportMapFragment einstellen? ich versucht, einige Antworten, die ich in ähnliche Fragen gefunden, wie dieser einen Mann namens Rob kaufen beantwortet, die vorgeschlagen:SupportMapFragment Set google maps Zoomstufe

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

Aber diese Lösung hat nicht funktioniert. Also, wie kann ich den Zoomlevel einstellen, wissend, dass ich einen SupportMapFragment benutze.

Antwort

1

wenn Ihre aktuelle Position nicht null ist dann diesen Code versuchen, es

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 arbeiten :) das funktioniert gut – 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

Danke Sarika: D – TeachMePls

+0

Sie willkommen :-) –

Verwandte Themen