简体   繁体   English

如何使标记出现在Google Map初始窗口的中心?

[英]How to make the marker appear in the center of the Google Map initial window?

I am using Google Maps V2 Android in my app. 我在我的应用程序中使用Google Maps V2 Android。

I place a marker at the point of Singapore. 我在新加坡点放置了一个标记。

But I notice every time my app starts up, the initial window is somewhat always South America. 但是我注意到,每次我的应用启动时,初始窗口总是在南美。

How may I make the map automatically zoom to Singapore area with the marker in the center? 如何以标记为中心自动将地图缩放到新加坡地区?

I place the marker as follows: 我将标记放置如下:

googleMapLocation = new LatLng(latitude, longitude);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
map.addMarker(new MarkerOptions().position(googleMapLocation).title("I am here!"));

您可以使用:

map.moveCamera(CameraUpdateFactory.newLatLngZoom(googleMapLocation, zoom));

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

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