【问题标题】:Remove default object from google maps api v2从谷歌地图 api v2 中删除默认对象
【发布时间】:2017-06-14 06:11:53
【问题描述】:

我想从谷歌地图中删除所有默认对象或地点。我希望知道这更容易还是在叠加层上构建更容易。我想要一张谷歌支持的空白地图。我会随时添加我需要的地方或对象,这可能吗? maps.clear() 没有添加任何帮助,我想要一些 onCreate() 方法或 onStart() 方法来删​​除所有地方并有一张没有地方只有道路和建筑物的空白地图。

public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mapReady = true;
    Double latitude = location.getLatitude();
    Double longitude = location.getLongitude();
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mMap.setMyLocationEnabled(true);
    // Add a marker in Sydney and move the camera
    //LatLng sydney = new LatLng(-34, 151);
    LatLng currentPosition = new LatLng(latitude,longitude);
    mMap.addMarker(new MarkerOptions().position(currentPosition).title("Current Location"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(currentPosition));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
    mMap.setMapType();
    loadNearByPlaces(latitude,longitude);
}

这是我使用的起始代码。如何修改它并让它做我需要的?

【问题讨论】:

    标签: android google-maps android-layout google-maps-markers google-maps-android-api-2


    【解决方案1】:

    如果您应用自定义样式,您可以隐藏地点和兴趣点的默认图标并实现您的目标。

    看看教程:

    https://developers.google.com/maps/documentation/android-api/styling

    样式向导位于:

    https://mapstyle.withgoogle.com/

    例如,要在地图上隐藏所有商家,您可以应用以下样式

    [
      {
        "featureType": "poi.business",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 2016-10-12
      • 2013-04-16
      • 2013-05-04
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      • 2011-03-25
      • 1970-01-01
      相关资源
      最近更新 更多