1

I have a googlemap.
On the Top of a googlemap I have another layout.
My problem is, The pinpointed location is covered by my Another layout.
How can I change the center of the map.
(Pls see example below at my photo).

So far this is my code.

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

    }
}  

I Want to achieve the Letter "B" picture.

enter image description here

Charles Galvez
  • 1,100
  • 5
  • 19
  • 41

3 Answers3

0

take a look at this answer: https://stackoverflow.com/a/19061524/5923606

CameraPosition cameraPosition = new CameraPosition.Builder()
    .target(new LatLng(Lat, Lon))
    .zoom(12)
    .build();
gMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Community
  • 1
  • 1
ugur
  • 3,604
  • 3
  • 26
  • 57
0

For this you will need CameraUpdate class and set the new LatLngBounds something similar to this

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

Here is the docs for changing map camera position. And it clearly states that you can't use pre-layout.

Gaurav Sarma
  • 2,248
  • 2
  • 24
  • 45
0

Simply add .target(new LatLng(latitude, longitude) The location that the camera is pointing at target.

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

Shweta Nandha
  • 728
  • 1
  • 8
  • 19