【问题标题】:how to open up a map of a particular city using google APIs in android如何在android中使用谷歌API打开特定城市的地图
【发布时间】:2014-11-24 15:22:14
【问题描述】:

我已经能够通过代码打开世界地图并标记几个地方。但是,我总是必须缩小到城市,这需要一点时间。有没有办法直接打开特定城市的地图?

【问题讨论】:

标签: android android-maps-v2 android-maps android-maps-extensions


【解决方案1】:

例如,您可以将 moveCamera 与您上次存储的位置(lat、lng 和 zoomLevel)一起使用。

final LatLng location = new LatLng(..., ...);// Loaded from SharedPreferences maybe.

// Move the camera to location with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 15));

【讨论】:

    【解决方案2】:

    您可以使用此示例代码将地图直接设置为您的城市坐标(lat、lng)并自动缩小到指定级别:

    // Set desired lat lng location, and zoom level (for example 10)
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(locationCity.getLatitude(), locationCity.getLongitude()), 10);
    // Move the camera to location
    gMap.animateCamera(cameraUpdate);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      • 1970-01-01
      • 2016-01-17
      • 2020-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多