2016-07-25 46 views
0

我有一个特定的位置,我想成为我的地图的中心。
我有以下代码:如何设置Google Map的特定中心?

theMap.moveCamera(
       CameraUpdateFactory.newLatLngZoom(
         new LatLng(
            location.getLatitude(), 
            location.getLongitude()), 17.0f 
         ) 
      ) 
); 
MarkerOptions markerOptions = new MarkerOptions() 
           .position(new LatLng(location.getLatitude(), location.getLongitude())); 
markerOptions.icon(createIcon()); 
theMap.addMarker(markerOptions); 

问题:地图上显示的位置和图标,但我想要的图标是在地图的中心。现在图标在边界内,但不在中心。
我该如何解决这个问题?

+0

你可以分享你的'createIcon()'方法并发布截图吗? – antonio

回答

1

按照Google Maps API

,你可以很容易地使用setCenter功能,如

theMap.setCenter(markerOptions.position);

panto平滑地显示,像

theMap.panTo(markerOptions.position);

Here是我写的一个例子show whats不同之间。