【问题标题】:Google map v2 marker not starting with my location谷歌地图 v2 标记不是从我的位置开始
【发布时间】:2014-05-23 03:01:23
【问题描述】:
        SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);

        googleMap = fm.getMap();

        googleMap.setMyLocationEnabled(true);

        Marker marker = googleMap.addMarker(new MarkerOptions()
                  .position(new LatLng(location.getLatitude(),location.getLongitude()))
                  .title("Me")
                  .snippet("Population: 776733"));

当我运行代码时,谷歌地图应该用标记显示我所在的地方,但地图正在与其他地方打开,没有我当前的位置,我必须手动移动到我的位置找到标记。

【问题讨论】:

  • 使用 animateCamera 或 moveCamera 将屏幕移动到您收到的标记位置

标签: android google-maps location android-maps-v2


【解决方案1】:

你应该在那个特定位置animateCameraMarker 点赞

LatLng current_loc= new LatLng(lat, lng);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(current_loc, 18.0f));

欲了解更多信息,请访问https://developers.google.com/maps/documentation/android/views#moving_the_camera

【讨论】:

    【解决方案2】:

    试试这个,

    googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(your latitude, you longitude)));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多