从 google 地图 api v2 中删除默认对象

Remove default object from google maps api v2

我想从 google 地图中删除所有默认对象或地点。我希望知道这是更容易还是在叠加层上构建更容易。我想要一张 google 支持的空白地图。我会随时添加我需要的地方或对象,这可以吗? 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);
}

这是我使用的起始码。如何修改它并使其满足我的需要?

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

看看教程:

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

样式向导位于:

https://mapstyle.withgoogle.com/

例如,要隐藏地图上的所有企业,您可以应用以下样式

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