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

青春壹個敷衍的年華 提交于 2019-12-10 10:08:15

问题


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


回答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




回答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;




回答3:


Try this,

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

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



回答4:


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


来源:https://stackoverflow.com/questions/42384482/how-to-place-a-marker-on-center-of-the-screen-on-google-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!