![](/img/trans.png)
[英]Google Map API V2 - How do I keep a marker in the center of the screen while user is scrolling the map?
[英]How to place a Marker on center of the screen on google map
将标记放在谷歌地图android屏幕的中心,就像在uber和ola应用程序中一样。 当移动或滚动谷歌地图标记不应移动,它应该给出latlng坐标
您需要使用框架布局来对齐您的标记,在这种情况下,像这样的图像在中心。 然后使用googleMap.getCameraPosition().target
获取位置
有关详细信息,请参阅http://developer.android.com/reference/com/google/android/gms/maps/model/CameraPosition.html#target
你需要把一个ImageView中心的frameLayout.That不是你的地图的标记,但是它放在中心,当你点击那个imageview你需要获得地图的中心LatLng
以下是获取地图中心LatLng的代码:
LatLng center = mgoogleMap.getCameraPosition()。target;
试试这个,
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.