简体   繁体   English

如何在谷歌地图上的屏幕中心放置标记

[英]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. 将标记放在谷歌地图android屏幕的中心,就像在uber和ola应用程序中一样。 When moving or scrolling a google map marker should not move and it should give latlng coordinates 当移动或滚动谷歌地图标记不应移动,它应该给出latlng坐标

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 然后使用googleMap.getCameraPosition().target获取位置

for more info see http://developer.android.com/reference/com/google/android/gms/maps/model/CameraPosition.html#target 有关详细信息,请参阅http://developer.android.com/reference/com/google/android/gms/maps/model/CameraPosition.html#target

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 你需要把一个ImageView中心的frameLayout.That不是你的地图的标记,但是它放在中心,当你点击那个imageview你需要获得地图的中心LatLng

Here is code for getting center LatLng of map : 以下是获取地图中心LatLng的代码:

LatLng center = mgoogleMap.getCameraPosition().target; LatLng center = mgoogleMap.getCameraPosition()。target;

Try this, 试试这个,

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

   googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM