2016-09-10 8 views
1

私はgooglemapを持っています。
Googleマップのトップに別のレイアウトがあります。
私の問題は、正確な場所は私の別のレイアウトでカバーされています。
マップの中心を変更するにはどうすればよいですか。
(写真は下の例をご覧ください)。Googleマップを変更するカメラの中心

これまでのところ私のコードです。

@Override 
public void onMapReady(GoogleMap googleMap) { 
    MapsInitializer.initialize(getApplicationContext()); 
    gMap = googleMap; 

    if (gMap != null) { 
     MarkerOptions markerOptions = new MarkerOptions(); 
     LatLng latLng = new LatLng(Double.parseDouble(App.getShopLat()), Double.parseDouble(App.getShopLng())); 
     markerOptions.position(latLng); 
     markerOptions.title(App.getShopname()); 
     gMap.addMarker(markerOptions); 

     gMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); 
     gMap.animateCamera(CameraUpdateFactory.zoomTo(12)); 

    } 
} 

私は文字「B」の画像を達成したいと思います。

enter image description here

答えて

0

この答えを見てみましょう:このためhttps://stackoverflow.com/a/19061524/5923606

CameraPosition cameraPosition = new CameraPosition.Builder() 
    .target(new LatLng(Lat, Lon)) 
    .zoom(12) 
    .build(); 
gMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 
0

をあなたがするCameraUpdateクラスを必要とし、新しいLatLngBoundsを設定しますこれに似たもの

// Width and height are calculated for your screen 
public static CameraUpdate newLatLngBounds(
    LatLngBounds bounds, int width, int height, int padding) 

がここにあります地図カメラの位置を変更するためのdocs。そして、それはあなたがプレレイアウトを使うことができないことを明確に述べています。

+0

私は何を置くべきです私の現在のコードにこれを実装する方法はありますか?ありがとう –

+0

私は、詳細のためにドキュメントに答えの外観を編集しました –

+0

それはうまく読めません。 Tnx –

0

単純.TARGET(新しい緯度経度(緯度、経度) にカメラがターゲットを指している場所を追加

例:
CameraPosition cPosition = new CameraPosition.Builder() .target(new LatLng(latitude, longitude)) //Sets the center of the map .zoom(18) .build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cPosition));

関連する問題