Krishna
Krishna

Reputation: 1634

How to place a Marker on center of the screen on google map

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

Upvotes: 3

Views: 5538

Answers (4)

Patel Jaymin
Patel Jaymin

Reputation: 251

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;

Upvotes: 2

param
param

Reputation: 493

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

Upvotes: 0

Komal12
Komal12

Reputation: 3348

Try this,

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

   googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Upvotes: 1

rohitanand
rohitanand

Reputation: 728

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

Upvotes: 1

Related Questions