3

Place marker on center of the screen on google map android same as like in uber and ola apps. When moving or scrolling a google map marker should not move and it should give latlng coordinates

Krishna
  • 1,556
  • 13
  • 21

4 Answers4

2

You need to put an ImageView center of frameLayout.That is not marker of your map but it place in the center and when you click that imageview you need to get center LatLng of the map

Here is code for getting center LatLng of map :

LatLng center = mgoogleMap.getCameraPosition().target;

Patel Jaimin
  • 231
  • 1
  • 11
1

You need to use frame layout to align your marker in this case a image like this at center. and then fetch location using googleMap.getCameraPosition().target

for more info see http://developer.android.com/reference/com/google/android/gms/maps/model/CameraPosition.html#target

rohitanand
  • 710
  • 1
  • 4
  • 26
1

Try this,

   CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(new LatLng(currentLatitude, currentLongitude)).zoom(15).build();

   googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Komal12
  • 3,340
  • 4
  • 16
  • 25
0
    Check Out This

    LatLng mapCoordinate = new LatLng(yourLatitude, yourLatitude);
    CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(mapCoordinate, 11.0f);
    yourMap.animateCamera(yourLocation);

    Or In Other way

   LatLng mapCoordinate = new LatLng(yourLatitude, yourLatitude);
    CameraPosition cameraPosition = new CameraPosition.Builder()
        .target(mapCoordinate) // set to Center
        .zoom(12.0f)                // for the Zoom
        .bearing(90)                // Orientation of the camera to east
        .tilt(30)                   // Tilt of the camera to 30 degrees
        .build();                   // Creates a CameraPosition
    yourMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
param
  • 393
  • 6
  • 17